KCoreAddons

ktexttohtml.h
1 /*
2  SPDX-FileCopyrightText: 2002 Dave Corrie <[email protected]>
3  SPDX-FileCopyrightText: 2014 Daniel Vrátil <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KCOREADDONS_KTEXTTOHTML_H
9 #define KCOREADDONS_KTEXTTOHTML_H
10 
11 #include <kcoreaddons_export.h>
12 
13 #include <QString>
14 
15 /**
16  * @author Dave Corrie <[email protected]>
17  */
18 namespace KTextToHTML
19 {
20 /**
21  * @see Options
22  * @since 5.5.0
23  */
24 enum Option {
25  /**
26  * Preserve white-space formatting of the text
27  */
28  PreserveSpaces = 1 << 1,
29 
30  /**
31  * Replace text emoticons smileys by emoticons images.
32  *
33  * @note
34  * This option works only when KEmoticons framework is available at runtime,
35  * and requires QGuiApplication, otherwise the flag is simply ignored.
36  */
37  ReplaceSmileys = 1 << 2,
38 
39  /**
40  * Don't parse and replace any URLs.
41  */
42  IgnoreUrls = 1 << 3,
43 
44  /**
45  * Interpret text highlighting markup, like *bold*, _underline_ and /italic/,
46  * and wrap them in corresponding HTML entities.
47  */
48  HighlightText = 1 << 4,
49 
50  /**
51  * Replace phone numbers with tel: links.
52  * @since 5.56.0
53  */
55 };
56 /**
57  * Stores a combination of #Option values.
58  */
59 Q_DECLARE_FLAGS(Options, Option)
60 Q_DECLARE_OPERATORS_FOR_FLAGS(Options)
61 
62 /**
63  * Converts plaintext into html. The following characters are converted
64  * to HTML entities: & " < >. Newlines are also preserved.
65  *
66  * @param plainText The text to be converted into HTML.
67  * @param options The options to use when processing @p plainText.
68  * @param maxUrlLen The maximum length of permitted URLs. The reason for
69  * this limit is that there may be possible security
70  * implications in handling URLs of unlimited length.
71  * @param maxAddressLen The maximum length of permitted email addresses.
72  * The reason for this limit is that there may be possible
73  * security implications in handling addresses of unlimited
74  * length.
75  *
76  * @return An HTML version of the text supplied in the 'plainText'
77  * parameter, suitable for inclusion in the BODY of an HTML document.
78  *
79  * @since 5.5.0
80  */
81 KCOREADDONS_EXPORT QString convertToHtml(const QString &plainText, const KTextToHTML::Options &options, int maxUrlLen = 4096, int maxAddressLen = 255);
82 
83 }
84 
85 #endif
@ ReplaceSmileys
Replace text emoticons smileys by emoticons images.
Definition: ktexttohtml.h:37
@ IgnoreUrls
Don't parse and replace any URLs.
Definition: ktexttohtml.h:42
KCOREADDONS_EXPORT QString convertToHtml(const QString &plainText, const KTextToHTML::Options &options, int maxUrlLen=4096, int maxAddressLen=255)
Converts plaintext into html.
@ ConvertPhoneNumbers
Replace phone numbers with tel: links.
Definition: ktexttohtml.h:54
@ PreserveSpaces
Preserve white-space formatting of the text.
Definition: ktexttohtml.h:28
@ HighlightText
Interpret text highlighting markup, like bold, underline and /italic/, and wrap them in corresponding...
Definition: ktexttohtml.h:48
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Sep 25 2023 04:01:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.