1 | /* |
2 | SPDX-FileCopyrightText: 2002 Dave Corrie <kde@davecorrie.com> |
3 | SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com> |
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 | * \namespace KTextToHTML |
17 | * \inmodule KCoreAddons |
18 | */ |
19 | namespace KTextToHTML |
20 | { |
21 | Q_NAMESPACE_EXPORT(KCOREADDONS_EXPORT) |
22 | /*! |
23 | * \since 5.5.0 |
24 | * |
25 | * \value PreserveSpaces Preserve white-space formatting of the text |
26 | * \value ReplaceSmileys Replace text emoticons smileys by emoticons images |
27 | * \value IgnoreUrls Don't parse and replace any URLs |
28 | * \value HighlightText Interpret text highlighting markup, like *bold*, _underline_ and /italic/, and wrap them in corresponding HTML entities |
29 | * \value [since 5.56] ConvertPhoneNumbers Replace phone numbers with tel: links |
30 | */ |
31 | enum Option { |
32 | PreserveSpaces = 1 << 1, |
33 | ReplaceSmileys = 1 << 2, |
34 | IgnoreUrls = 1 << 3, |
35 | HighlightText = 1 << 4, |
36 | ConvertPhoneNumbers = 1 << 5, |
37 | }; |
38 | Q_DECLARE_FLAGS(Options, Option) |
39 | Q_DECLARE_OPERATORS_FOR_FLAGS(Options) |
40 | Q_FLAG_NS(Options) |
41 | |
42 | /*! |
43 | * Converts plaintext into html. The following characters are converted |
44 | * to HTML entities: & " < >. Newlines are also preserved. |
45 | * |
46 | * \a plainText The text to be converted into HTML. |
47 | * |
48 | * \a options The options to use when processing \a plainText. |
49 | * |
50 | * \a maxUrlLen The maximum length of permitted URLs. The reason for |
51 | * this limit is that there may be possible security |
52 | * implications in handling URLs of unlimited length. |
53 | * |
54 | * \a maxAddressLen The maximum length of permitted email addresses. |
55 | * The reason for this limit is that there may be possible |
56 | * security implications in handling addresses of unlimited |
57 | * length. |
58 | * |
59 | * Returns an HTML version of the text supplied in the 'plainText' |
60 | * parameter, suitable for inclusion in the BODY of an HTML document. |
61 | * |
62 | * \since 5.5.0 |
63 | */ |
64 | KCOREADDONS_EXPORT QString convertToHtml(const QString &plainText, const KTextToHTML::Options &options, int maxUrlLen = 4096, int maxAddressLen = 255); |
65 | |
66 | } |
67 | |
68 | #endif |
69 | |