QTextMarkdownWriter: Don't word-wrap headings
If it wraps, the text on the next line is no longer part of the heading. Fixes: QTBUG-106526 Change-Id: I8015c948d875c6944422ef3439e3128af5b2a2e2 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 65c40290b488395ee7c1fdfabc4d274889d9afab) Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit a7367e6a3cd8796401fd8090500954528ba962da) (cherry picked from commit d16ef4d14c237fa7536662bd69d1702ce3b37e90) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a5a8d9f38a
commit
4adfe84acb
@ -435,10 +435,12 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
|
||||
m_indentedCodeBlock = true;
|
||||
}
|
||||
}
|
||||
if (blockFmt.headingLevel())
|
||||
if (blockFmt.headingLevel()) {
|
||||
m_stream << QByteArray(blockFmt.headingLevel(), '#') << ' ';
|
||||
else
|
||||
wrap = false;
|
||||
} else {
|
||||
m_stream << m_linePrefix;
|
||||
}
|
||||
|
||||
QString wrapIndentString = m_linePrefix + QString(m_wrappedLineIndent, qtmw_Space);
|
||||
// It would be convenient if QTextStream had a lineCharPos() accessor,
|
||||
|
@ -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.
|
||||
|
@ -512,6 +512,7 @@ void tst_QTextMarkdownWriter::rewriteDocument_data()
|
||||
QTest::newRow("word wrap") << "wordWrap.md";
|
||||
QTest::newRow("links") << "links.md";
|
||||
QTest::newRow("lists and code blocks") << "listsAndCodeBlocks.md";
|
||||
QTest::newRow("long headings") << "longHeadings.md";
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::rewriteDocument()
|
||||
|
Loading…
x
Reference in New Issue
Block a user