TextUtils::TextUtilsTextToHtml Namespace

Header: #include <textutilstexttohtml.h>
CMake: find_package(KF6TextUtils REQUIRED)
target_link_libraries(mytarget PRIVATE KF6::TextUtils)

Types

enum Option { PreserveSpaces, ReplaceSmileys, IgnoreUrls, HighlightText, ConvertPhoneNumbers }
flags Options

Functions

QString convertToHtml(const QString &plainText, const TextUtils::TextUtilsTextToHtml::Options &options, int maxUrlLen = 4096, int maxAddressLen = 255)

Detailed Description

Copied from KTextToHTML (KCoreAddons), with its parsing optimizations.

Type Documentation

enum TextUtilsTextToHtml::Option
flags TextUtilsTextToHtml::Options

ConstantValueDescription
TextUtils::TextUtilsTextToHtml::PreserveSpaces1 << 1Preserve white-space formatting of the text
TextUtils::TextUtilsTextToHtml::ReplaceSmileys1 << 2Replace text emoticons smileys by emoticons images
TextUtils::TextUtilsTextToHtml::IgnoreUrls1 << 3Don't parse and replace any URLs
TextUtils::TextUtilsTextToHtml::HighlightText1 << 4Interpret text highlighting markup, like *bold*, _underline_ and /italic/, and wrap them in corresponding HTML entities
TextUtils::TextUtilsTextToHtml::ConvertPhoneNumbers1 << 5Replace phone numbers with tel: links

The Options type is a typedef for QFlags<Option>. It stores an OR combination of Option values.

Function Documentation

QString TextUtilsTextToHtml::convertToHtml(const QString &plainText, const TextUtils::TextUtilsTextToHtml::Options &options, int maxUrlLen = 4096, int maxAddressLen = 255)

Converts plaintext into html. The following characters are converted to HTML entities: & " < >. Newlines are also preserved.

plainText The text to be converted into HTML.

options The options to use when processing plainText.

maxUrlLen The maximum length of permitted URLs. The reason for this limit is that there may be possible security implications in handling URLs of unlimited length.

maxAddressLen The maximum length of permitted email addresses. The reason for this limit is that there may be possible security implications in handling addresses of unlimited length.

Returns an HTML version of the text supplied in the 'plainText' parameter, suitable for inclusion in the BODY of an HTML document.