summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-04-21 21:40:01 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-04-21 21:40:01 +0200
commita15c7260cc83707dcdd05d7d9c23317536601fdc (patch)
tree3f60e05467b1a9f38a692e37a4e44675baf71732 /src/gui
parent47eba459905ef884931aa1247c847f7a98a77b28 (diff)
parente10e5318bc02a48a866b76b6f0b7f268d16af642 (diff)
Merge remote-tracking branch 'origin/5.15' into 5.15.0
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qtextmarkdownwriter.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp
index 7bd321becc..ae63fcb4dd 100644
--- a/src/gui/text/qtextmarkdownwriter.cpp
+++ b/src/gui/text/qtextmarkdownwriter.cpp
@@ -367,6 +367,14 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
const int ColumnLimit = 80;
QTextBlockFormat blockFmt = block.blockFormat();
bool missedBlankCodeBlockLine = false;
+ const bool codeBlock = blockFmt.hasProperty(QTextFormat::BlockCodeFence) ||
+ blockFmt.stringProperty(QTextFormat::BlockCodeLanguage).length() > 0;
+ if (m_fencedCodeBlock && !codeBlock) {
+ m_stream << m_linePrefix << QString(m_wrappedLineIndent, Space)
+ << m_codeBlockFence << Newline;
+ m_fencedCodeBlock = false;
+ m_codeBlockFence.clear();
+ }
if (block.textList()) { // it's a list-item
auto fmt = block.textList()->format();
const int listLevel = fmt.indent();
@@ -427,7 +435,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
} else if (blockFmt.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) {
m_stream << "- - -\n"; // unambiguous horizontal rule, not an underline under a heading
return 0;
- } else if (blockFmt.hasProperty(QTextFormat::BlockCodeFence) || blockFmt.stringProperty(QTextFormat::BlockCodeLanguage).length() > 0) {
+ } else if (codeBlock) {
// It's important to preserve blank lines in code blocks. But blank lines in code blocks
// inside block quotes are getting preserved anyway (along with the "> " prefix).
if (!blockFmt.hasProperty(QTextFormat::BlockQuoteLevel))
@@ -439,16 +447,11 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
m_codeBlockFence = QString(3, fenceChar.at(0));
// A block quote can contain an indented code block, but not vice-versa.
m_stream << m_linePrefix << QString(m_wrappedLineIndent, Space) << m_codeBlockFence
- << Space << blockFmt.stringProperty(QTextFormat::BlockCodeLanguage) << Newline;
+ << blockFmt.stringProperty(QTextFormat::BlockCodeLanguage) << Newline;
m_fencedCodeBlock = true;
}
+ wrap = false;
} else if (!blockFmt.indent()) {
- if (m_fencedCodeBlock) {
- m_stream << m_linePrefix << QString(m_wrappedLineIndent, Space)
- << m_codeBlockFence << Newline;
- m_fencedCodeBlock = false;
- m_codeBlockFence.clear();
- }
m_wrappedLineIndent = 0;
m_linePrefix.clear();
if (blockFmt.hasProperty(QTextFormat::BlockQuoteLevel)) {