Comments (3)
The CommonMark spec says that the blockquote should be rendered as a single paragraph with a soft break separating the two lines. If we run your Markdown through our XmlRenderer
instead we see that it indeed separates the two lines with a soft break:
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns="http://commonmark.org/xml/1.0">
<paragraph>
<text>The text</text>
</paragraph>
<block_quote>
<paragraph>
<text>Blockquote Line 1</text>
<softbreak />
<text>Blockquote Line 2</text>
</paragraph>
</block_quote>
<paragraph>
<text>The other Text</text>
</paragraph>
</document>
Which matches how the JS reference parser handles this (see the AST tab). Indeed, all CommonMark-compliant parsers seem to handle this case the same way.
My best guess is that GitHub.com might have their GFM parser to render those soft breaks as hard breaks (<br>
) instead of \n
. If you'd like that same behavior, you can set the renderer
ยป soft_break
configuration option accordingly:
$environment = new Environment([
'renderer' => [
'soft_break' => '<br>',
],
]);
$environment->addExtension(new CommonMarkCoreExtension());
$environment->addExtension(new GithubFlavoredMarkdownExtension());
$converter = new MarkdownConverter($environment);
echo $converter->convert('The text
> Blockquote Line 1
> Blockquote Line 2
The other Text');
Give that a try and let me know if that helps!
from commonmark.
Give that a try and let me know if that helps!
Yes, that helps with my issue. Thanks for the explaining as well.
My best guess is that GitHub.com might have their GFM parser to render those soft breaks as hard breaks (
<br>
) instead of\n
. If you'd like that same behavior, you can set therenderer
ยปsoft_break
configuration option accordingly:
Perhaps the GFM should be used hard breaks by default? Or perhaps I'm the only one who was/is confused about the difference.
Anyway, thanks a lot :-)
from commonmark.
Yes, that helps with my issue. Thanks for the explaining as well.
Great! I'm glad I could help :)
Perhaps the GFM should be used hard breaks by default? Or perhaps I'm the only one who was/is confused about the difference.
๐ค I'm inclined to keep the current behavior as-is, primarily because it matches the out-of-box behavior of their parser (even if they might configure it differently when using it on their site). But if anyone else stumbles upon this issue in the future and makes a strong case in favor of this idea, I will certainly consider it.
from commonmark.
Related Issues (20)
- Delimiter processor cannot have a space right after opener and/or before closer HOT 1
- Weird interaction of code block with other block parsers HOT 1
- Add newer GFM features HOT 5
- Exception when setting unordered_list_markers; exception when *not* setting unordered_list_markers HOT 1
- Can it compare two md contents?
- Add support for github admonition HOT 1
- HeadingPermalinkExtension does not percent-encode CJK names, but commonmark does percent-encode CJK URLs
- addRenderer and addExtension inconsistency HOT 2
- HeadingPermalinkRenderer Accessibility HOT 6
- Maximum execution time exceeded in Parser/Cursor.php when processing large base64 string.
- FencedCodePar
- Markdown to Shell HOT 2
- Abbreviated decade (e.g. โ80s) breaks smart punctuation HOT 1
- [FALSE REPORT] GPL-licensed dependencies :( HOT 2
- Running with PHP 8.4 produces deprecation notices HOT 4
- lineStart in Table Extension does not yield the correct line
- add getLineOffset() to MarkdownInput
- Problems with QuoteParser.php file permissions HOT 1
- Embed extension adds iframe two times HOT 3
- Autolinks - URls within HTML produces invalid HTML HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commonmark.