summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/text/qtextmarkdownwriter.cpp4
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/longHeadings.md9
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp1
3 files changed, 13 insertions, 1 deletions
diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp
index 8cce9df0dd..011658d2d9 100644
--- a/src/gui/text/qtextmarkdownwriter.cpp
+++ b/src/gui/text/qtextmarkdownwriter.cpp
@@ -481,8 +481,10 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
m_linePrefixWritten = true;
}
}
- if (blockFmt.headingLevel())
+ if (blockFmt.headingLevel()) {
m_stream << QByteArray(blockFmt.headingLevel(), '#') << ' ';
+ wrap = false;
+ }
QString wrapIndentString = m_linePrefix + QString(m_wrappedLineIndent, qtmw_Space);
// It would be convenient if QTextStream had a lineCharPos() accessor,
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/longHeadings.md b/tests/auto/gui/text/qtextmarkdownwriter/data/longHeadings.md
new file mode 100644
index 0000000000..72692b4845
--- /dev/null
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/longHeadings.md
@@ -0,0 +1,9 @@
+# The quick brown fox jumped over the lazy dog while the cat played the fiddle and the cow jumped over the moon
+
+Hey diddle diddle
+
+## This document has a verbose subheading too, which we do not expect to wrap in the output
+
+Qt can write it right. Long text here in this paragraph will actually wrap,
+even though its heading doesn't.
+
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
index 5ff4ed2306..dae28f020d 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
+++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
@@ -634,6 +634,7 @@ void tst_QTextMarkdownWriter::rewriteDocument_data()
QTest::newRow("links") << "links.md";
QTest::newRow("lists and code blocks") << "listsAndCodeBlocks.md";
QTest::newRow("front matter") << "yaml.md";
+ QTest::newRow("long headings") << "longHeadings.md";
}
void tst_QTextMarkdownWriter::rewriteDocument()