diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-06-15 16:50:44 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-05-14 21:32:05 +0200 |
commit | 7c7606460403e6495b860134f28e8d4d45c6c810 (patch) | |
tree | 8b360ddd4bf22c21af468fb1c736c9d96c646c20 /src/gui/text/qtextdocumentfragment.h | |
parent | e69ebf93ca49d2c3de9fc723c744fbcb21709bb3 (diff) |
Add QTextDocFragment::to/fromMarkdown() & QTextCursor::insertMarkdown()
Also add the beginnings of an autotest for QTextCursor::insertHtml(),
for comparison purposes.
We can see that the block to be inserted is merged with an existing
block by default rather than being inserted as a new one, with both HTML and
Markdown insertions. So now we test for leading and trailing newlines
in the markdown to be inserted, to determine whether we need a new block
into which to insert, and to "hit enter" at the end of the insertion.
QSKIP the toMarkdown() comparisons if GeneralFont is mono. This happens
on Boot2Qt systems in CI.
Task-number: QTBUG-76105
Task-number: QTBUG-94462
Task-number: QTBUG-100515
Task-number: QTBUG-103484
Change-Id: I51a05c6a7cd0be4f2817f4a922f45fa663982293
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/text/qtextdocumentfragment.h')
-rw-r--r-- | src/gui/text/qtextdocumentfragment.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gui/text/qtextdocumentfragment.h b/src/gui/text/qtextdocumentfragment.h index 37d7006ae6..3c23e403e0 100644 --- a/src/gui/text/qtextdocumentfragment.h +++ b/src/gui/text/qtextdocumentfragment.h @@ -41,13 +41,13 @@ #define QTEXTDOCUMENTFRAGMENT_H #include <QtGui/qtguiglobal.h> +#include <QtGui/qtextdocument.h> #include <QtCore/qstring.h> QT_BEGIN_NAMESPACE class QTextStream; -class QTextDocument; class QTextDocumentFragmentPrivate; class QTextCursor; @@ -68,11 +68,18 @@ public: #ifndef QT_NO_TEXTHTMLPARSER QString toHtml() const; #endif // QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(textmarkdownwriter) + QString toMarkdown(QTextDocument::MarkdownFeatures features = QTextDocument::MarkdownDialectGitHub) const; +#endif static QTextDocumentFragment fromPlainText(const QString &plainText); #ifndef QT_NO_TEXTHTMLPARSER static QTextDocumentFragment fromHtml(const QString &html, const QTextDocument *resourceProvider = nullptr); #endif // QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(textmarkdownreader) + static QTextDocumentFragment fromMarkdown(const QString &markdown, + QTextDocument::MarkdownFeatures features = QTextDocument::MarkdownDialectGitHub); +#endif private: QTextDocumentFragmentPrivate *d; |