diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-05-13 12:58:37 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-05-24 15:37:05 +0200 |
commit | 7224d0e427d71e559b928c44634839b4791c1416 (patch) | |
tree | 86a327b5a31c52a2e94b6d6158a96ac05f63f052 /src/gui/text/qtextmarkdownimporter_p.h | |
parent | 2c8fa9700cb1eb5f1587bec46b7060ec93c6b1d2 (diff) |
QTextMarkdownImporter: don't keep heading level on following list item
When reading a document like
# heading
- list item
and then re-writing it, it turned into
# heading
- # list item
because QTextCursor::insertList() simply calls QTextCursor::insertBlock(), thus
inheriting block format from the previous block, without an opportunity to
explicitly define the block format. So be more consistent: use
QTextMarkdownImporter::insertBlock() for blocks inside list items too. Now it
fully defines blockFormat first, then inserts the block, and then adds it to
the current list only when the "paragraph" is actually the list item's text
(but not when it's a continuation paragraph). Also, be prepared for applying
and removing block markers to arbitrary blocks, just in case (they might be
useful for block quotes, for example).
Change-Id: I391820af9b65e75abce12abab45d2477c49c86ac
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/gui/text/qtextmarkdownimporter_p.h')
-rw-r--r-- | src/gui/text/qtextmarkdownimporter_p.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h index d62f1cf7dd..f905aa0f87 100644 --- a/src/gui/text/qtextmarkdownimporter_p.h +++ b/src/gui/text/qtextmarkdownimporter_p.h @@ -123,14 +123,15 @@ private: int m_tableRowCount = 0; int m_tableCol = -1; // because relative cell movements (e.g. m_cursor->movePosition(QTextCursor::NextCell)) don't work int m_paragraphMargin = 0; - Features m_features; int m_blockType = 0; - bool m_emptyList = false; // true when the last thing we did was insertList - bool m_listItem = false; - bool m_emptyListItem = false; + Features m_features; + QTextListFormat m_listFormat; + QTextBlockFormat::MarkerType m_markerType = QTextBlockFormat::NoMarker; + bool m_needsInsertBlock = false; + bool m_needsInsertList = false; + bool m_listItem = false; // true from the beginning of LI to the end of the first P bool m_codeBlock = false; bool m_imageSpan = false; - bool m_needsInsertBlock = false; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QTextMarkdownImporter::Features) |