Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard line breaks are not working in .md files #265

Open
WouterHouwen opened this issue Jun 10, 2021 · 5 comments
Open

Hard line breaks are not working in .md files #265

WouterHouwen opened this issue Jun 10, 2021 · 5 comments
Labels
bad output rinohtype's output is not correct bug

Comments

@WouterHouwen
Copy link

According to the specs of CommonMark, you can set a hard line break by adding 2 or more spaces at the end of a line that is not the end of a block.

Here is an example markdown file: line_break.md
The PDF output is this: line_break.pdf

The expected output is that "This should be on the next line" is on the next line.

The command I used to create the PDF is: rinoh line_break.md

commonmark.js shows it correctly https://spec.commonmark.org/dingus/?text=The%20following%20text%20should%20be%20on%20a%20new%20line%20%20%0A%22This%20should%20be%20on%20the%20next%20line%22%0A

CommonMark hard line break spec: https://spec.commonmark.org/0.29/#hard-line-break

Installed versions:

@WouterHouwen WouterHouwen added bad output rinohtype's output is not correct bug labels Jun 10, 2021
@brechtm
Copy link
Owner

brechtm commented Jun 10, 2021

recommonmark, the library rinohtype relies on for CommonMark support, translates this line break to a raw HTML node. rinohtype ignores raw nodes meant for other docutils writers (as it should).

Output from cm2pseudoxml line_break.md:

<document source="line_break.md">
    <paragraph>
        The following text should be on a new line
        <raw format="html" xml:space="preserve">
            <br />
        "
        This should be on the next line
        "

I think recommonmark outputs a raw node because docutils doesn't offer a hard line break node, as far as I know. Instead, recommonmark should transform a paragraph containing a hard line break to a line block so that it can be rendered properly by non-HTML writers.

You could open a ticket with recommonmark, but I see that package is now deprecated, so we might need to move away from it. The README recommends using MyST instead. Another option is pycmark.

@chrisjsewell
Copy link

You could open a ticket with recommonmark, but I see that package is now deprecated, so we might need to move away from it. The README recommends using MyST instead.

Heya, author of MyST here, certainly interested in rinohtype supporting MyST, since we were looking at in for https://github.com/executablebooks/jupyter-book 😄

cc @choldgraf

@brechtm
Copy link
Owner

brechtm commented Sep 2, 2021

Heya, author of MyST here, certainly interested in rinohtype supporting MyST, since we were looking at in for https://github.com/executablebooks/jupyter-book 😄

That would be a great use case for rinohtype!

If MyST can output to a plain docutils/Sphinx document tree, adding a MyST frontend to rinohtype should be trivial (see the CommonMark frontend code for reference). Is this something you want to try and implement? I'll be on vacation until late September, but I can help out when I'm back.

@chrisjsewell
Copy link

chrisjsewell commented Sep 2, 2021

If MyST can output to a plain docutils/Sphinx document tree

It can indeed 👍
Yeh same, I probably won’t have much/any time in September anyway, but certainly something I or one of the team would like to try thanks, when I can find the time 😬

@brechtm
Copy link
Owner

brechtm commented Oct 19, 2022

@chrisjsewell Reminded of this by #370, I had a go at replacing recommonmark with MyST and it turned out to be dead-simple! I did see an issue with relative links, however: #370 (comment)

Also, the line break issue described in this very issue persists with MyST. (using trailing spaces to indicate a line break -- or anything else, really -- is a horrible choice though /rant)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bad output rinohtype's output is not correct bug
Projects
None yet
Development

No branches or pull requests

3 participants