KTextToHTML Namespace

Header: #include <KTextToHTML>
CMake: find_package(KF6 REQUIRED COMPONENTS CoreAddons)
target_link_libraries(mytarget PRIVATE KF6::CoreAddons)

Types

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

Functions

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

Detailed Description

Type Documentation

enum KTextToHTML::Option
flags KTextToHTML::Options

ConstantValueDescription
KTextToHTML::PreserveSpaces1 << 1Preserve white-space formatting of the text
KTextToHTML::ReplaceSmileys1 << 2Replace text emoticons smileys by emoticons images
KTextToHTML::IgnoreUrls1 << 3Don't parse and replace any URLs
KTextToHTML::HighlightText1 << 4Interpret text highlighting markup, like *bold*, _underline_ and /italic/, and wrap them in corresponding HTML entities
KTextToHTML::ConvertPhoneNumbers (since 5.56)1 << 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 KTextToHTML::convertToHtml(const QString &plainText, const KTextToHTML::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.