File indexing completed on 2024-12-08 04:33:11

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