From 65314b6ce88cdbb28a22be0cab9856ec9bc9604b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 18 Dec 2017 08:55:18 +0100 Subject: Add QTextMarkdownImporter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This provides the ability to read from a Markdown string or file into a QTextDocument, such that the formatting will be recognized and can be rendered. - Add QTextDocument::setMarkdown(QString) - Add QTextEdit::setMarkdown(QString) - Add TextFormat::MarkdownText - QWidgetTextControl::setContent() calls QTextDocument::setMarkdown() if that's the format Fixes: QTBUG-72349 Change-Id: Ief2ad71bf840666c64145d58e9ca71d05fad5659 Reviewed-by: Lisandro Damián Nicanor Pérez Meyer Reviewed-by: Gatis Paeglis --- src/gui/text/qtextdocument.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/gui/text/qtextdocument.h') diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index c9b22e053b..ade67999ad 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -151,6 +151,19 @@ public: void setHtml(const QString &html); #endif +#if QT_CONFIG(textmarkdownreader) + // Must be in sync with QTextMarkdownImporter::Features, should be in sync with #define MD_FLAG_* in md4c + enum MarkdownFeature { + MarkdownNoHTML = 0x0020 | 0x0040, + MarkdownDialectCommonMark = 0, + MarkdownDialectGitHub = 0x0004 | 0x0008 | 0x0400 | 0x0100 | 0x0200 | 0x0800 + }; + Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature) + Q_FLAG(MarkdownFeatures) + + void setMarkdown(const QString &markdown, MarkdownFeatures features = MarkdownDialectGitHub); +#endif + QString toRawText() const; QString toPlainText() const; void setPlainText(const QString &text); -- cgit v1.2.3