Markdown writer: omit space after opening code block fence

The CommonMark spec shows that it's not necessary to have a space
between the code fence and the language string:
https://spec.commonmark.org/0.29/#example-112
This also avoids a needless trailing space after a code fence that
does not include a language string.

Change-Id: I2addd38a196045a7442150760b73269bfe4ffb22
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Shawn Rutledge 2020-04-19 01:24:05 +02:00
parent 0fcd782bd3
commit 51a348b2e2
4 changed files with 7 additions and 7 deletions

View File

@ -447,7 +447,7 @@ 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;

View File

@ -20,7 +20,7 @@ MacFarlane writes:
> equivalent sample of Markdown. Here is a sample of AsciiDoc from the AsciiDoc
> manual:
> ``` AsciiDoc
> ```AsciiDoc
> 1. List item one.
> +
> List item one continued with a second paragraph followed by an
@ -50,7 +50,7 @@ Now let's have an indented code block:
}
and end with a fenced code block:
~~~ pseudocode
~~~pseudocode
#include <something.h>
#include <else.h>

View File

@ -1,6 +1,6 @@
- something happens in the debugger like this:
```
```
1 QQuickEventPoint::setGrabberItem qquickevents.cpp 869 0x7ffff7a963f2
2 QQuickItem::grabMouse qquickitem.cpp 7599 0x7ffff7abea29
3 QQuickWindowPrivate::deliverMatchingPointsToItem qquickwindow.cpp 2738 0x7ffff7aea34c
@ -16,8 +16,8 @@
- something I tried to fix it:
```
code goes here, probably c++
```c++
item->ungrab();
```
- still didn't fix it, expecting a breakthrough any day now
- some sort of miracle

View File

@ -432,7 +432,7 @@ void tst_QTextMarkdownWriter::fromHtml_data()
"![foo](/url \"title\")\n\n";
QTest::newRow("code") <<
"<pre class=\"language-pseudocode\">\n#include \"foo.h\"\n\nblock {\n statement();\n}\n\n</pre>" <<
"``` pseudocode\n#include \"foo.h\"\n\nblock {\n statement();\n}\n```\n\n";
"```pseudocode\n#include \"foo.h\"\n\nblock {\n statement();\n}\n```\n\n";
// TODO
// QTest::newRow("escaped number and paren after double newline") <<
// "<p>(The first sentence of this paragraph is a line, the next paragraph has a number</p>13) but that's not part of an ordered list" <<