GithubHelp home page GithubHelp logo

Comments (3)

colinodell avatar colinodell commented on September 20, 2024 1

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.

basteyy avatar basteyy commented on September 20, 2024

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 the renderer ยป 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.

colinodell avatar colinodell commented on September 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.