1 // Copyright 2005-2019 The Mumble Developers. All rights reserved.
2 // Use of this source code is governed by a BSD-style license
3 // that can be found in the LICENSE file at the root of the
4 // Mumble source tree or at <https://www.mumble.info/LICENSE>.
5 
6 #ifndef MUMBLE_MUMBLE_XMLTOOLS_H_
7 #define MUMBLE_MUMBLE_XMLTOOLS_H_
8 
9 #include <QObject>
10 #include <QMap>
11 #include <QXmlStreamReader>
12 #include <QXmlStreamWriter>
13 
14 class XMLTools : public QObject {
15 		Q_OBJECT
16 	public:
17 		/* Recursively parse and output XHTML.
18 		 * This will drop <head>, <html> etc, take the contents of <body> and strip out unnecesarry styles.
19 		 * It will also change <span style=""> into matching <b>, <i> or <u>.
20 		 */
21 		static void recurseParse(QXmlStreamReader &reader,
22 		                         QXmlStreamWriter &writer,
23 		                         int &paragraphs,
24 		                         const QMap<QString, QString> &opstyle,
25 		                         const int close = 0, bool ignore = true);
26 
27 		/* Iterate XML and remove close-followed-by-open.
28 		 * For example, make "<b>bold with </b><b><i>italic</i></b>" into
29 		 * "<b>bold with <i>italic</i></b>"
30 		 *
31 		 * If the input XML is or may not be valid, a "unduplicate" tag can be used as a root element,
32 		 * which will be dropped and not written to writer.
33 		 *
34 		 * Input XML has to be valid XML.
35 		 *
36 		 * Works on b, i, u, and a elements.
37 		 */
38 		static bool unduplicateTags(QXmlStreamReader &reader, QXmlStreamWriter &writer);
39 };
40 
41 #endif // XMLTOOLS_H
42