summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-04-26 08:29:07 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-05-08 20:28:37 +0000
commit76716c4a9adc3f9aeb251d3ebe4d1d0be38b97ee (patch)
tree417bbd65fe3911d2ffddef20f05f15bb023f7d7d /src/gui/text
parent040dd7fe26bfa34aae19e2db698ff0d69346ed56 (diff)
Markdown: deal with horizontal rules (thematic breaks)
Change-Id: I14d4bcfe1a6c3bd87d1328f0abb81b2138545e4e Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextmarkdownimporter.cpp3
-rw-r--r--src/gui/text/qtextmarkdownwriter.cpp3
2 files changed, 5 insertions, 1 deletions
diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp
index a65d8f270e..5cee01d932 100644
--- a/src/gui/text/qtextmarkdownimporter.cpp
+++ b/src/gui/text/qtextmarkdownimporter.cpp
@@ -273,7 +273,8 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det)
m_currentTable = m_cursor->insertTable(1, 1); // we don't know the dimensions yet
break;
case MD_BLOCK_HR: {
- QTextBlockFormat blockFmt = m_cursor->blockFormat();
+ qCDebug(lcMD, "HR");
+ QTextBlockFormat blockFmt;
blockFmt.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, 1);
m_cursor->insertBlock(blockFmt, QTextCharFormat());
} break;
diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp
index 2f4c8587ad..0634d324b1 100644
--- a/src/gui/text/qtextmarkdownwriter.cpp
+++ b/src/gui/text/qtextmarkdownwriter.cpp
@@ -309,6 +309,9 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
prefix += QLatin1String(bullet) + Space;
}
m_stream << prefix;
+ } else if (block.blockFormat().hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) {
+ m_stream << "- - -\n"; // unambiguous horizontal rule, not an underline under a heading
+ return 0;
} else if (!block.blockFormat().indent()) {
m_wrappedLineIndent = 0;
}