File indexing completed on 2024-04-14 03:51:38
0001 /* 0002 SPDX-FileCopyrightText: 2002 Dave Corrie <kde@davecorrie.com> 0003 SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KCOREADDONS_KTEXTTOHTML_H 0009 #define KCOREADDONS_KTEXTTOHTML_H 0010 0011 #include <kcoreaddons_export.h> 0012 0013 #include <QString> 0014 0015 /** 0016 * @author Dave Corrie \<kde@davecorrie.com\> 0017 */ 0018 namespace KTextToHTML 0019 { 0020 /** 0021 * @see Options 0022 * @since 5.5.0 0023 */ 0024 enum Option { 0025 /** 0026 * Preserve white-space formatting of the text 0027 */ 0028 PreserveSpaces = 1 << 1, 0029 0030 /** 0031 * Replace text emoticons smileys by emoticons images. 0032 * 0033 * @note 0034 * This option works only when KEmoticons framework is available at runtime, 0035 * and requires QGuiApplication, otherwise the flag is simply ignored. 0036 */ 0037 ReplaceSmileys = 1 << 2, 0038 0039 /** 0040 * Don't parse and replace any URLs. 0041 */ 0042 IgnoreUrls = 1 << 3, 0043 0044 /** 0045 * Interpret text highlighting markup, like *bold*, _underline_ and /italic/, 0046 * and wrap them in corresponding HTML entities. 0047 */ 0048 HighlightText = 1 << 4, 0049 0050 /** 0051 * Replace phone numbers with tel: links. 0052 * @since 5.56.0 0053 */ 0054 ConvertPhoneNumbers = 1 << 5, 0055 }; 0056 /** 0057 * Stores a combination of #Option values. 0058 */ 0059 Q_DECLARE_FLAGS(Options, Option) 0060 Q_DECLARE_OPERATORS_FOR_FLAGS(Options) 0061 0062 /** 0063 * Converts plaintext into html. The following characters are converted 0064 * to HTML entities: & " < >. Newlines are also preserved. 0065 * 0066 * @param plainText The text to be converted into HTML. 0067 * @param options The options to use when processing @p plainText. 0068 * @param maxUrlLen The maximum length of permitted URLs. The reason for 0069 * this limit is that there may be possible security 0070 * implications in handling URLs of unlimited length. 0071 * @param maxAddressLen The maximum length of permitted email addresses. 0072 * The reason for this limit is that there may be possible 0073 * security implications in handling addresses of unlimited 0074 * length. 0075 * 0076 * @return An HTML version of the text supplied in the 'plainText' 0077 * parameter, suitable for inclusion in the BODY of an HTML document. 0078 * 0079 * @since 5.5.0 0080 */ 0081 KCOREADDONS_EXPORT QString convertToHtml(const QString &plainText, const KTextToHTML::Options &options, int maxUrlLen = 4096, int maxAddressLen = 255); 0082 0083 } 0084 0085 #endif