Pandoc: markdown_github line break behavior

Created on 20 Apr 2017  路  7Comments  路  Source: jgm/pandoc

All that this Github help page says about paragraphs and line breaks is:

You can create a new paragraph by leaving a blank line between lines of text.

Because this doesn't override the standard markdown behaviour for paragraphs and line breaks, it's reasonable to assume it will behave in the same way as standard markdown.

However:

echo -e "abc\ndef" | pandoc -f markdown_github

results in:

<p>abc<br />
def</p>

but should, like with markdown_strict, result in:

<p>abc def</p>
Markdown reader

Most helpful comment

Related stackoverflow question: http://stackoverflow.com/questions/24575680/new-lines-inside-paragraph-in-readme-md

The non-linebreaking behavior can be forced by using markdown_github-hard_line_breaks.

All 7 comments

it's reasonable to assume it will behave in the same way as standard markdown.

maybe it would be reasonable, but it is not so. e.g.:

abc
def

renders here on GitHub as:

abc
def

Please also consider asking questions like this on pandoc-discuss, the issue tracker is for bugs.

Sorry, I didn't follow that. When you say "it's not so" what are you basing that on? The behaviour of pandoc? On Github itself,

abc
def

is rendered just as I said it should be:

abc def

That indicates that this is a bug on pandoc. Have I missed something?!

is rendered just as I said it should be:

@rmwiseman are you sure? I just tried in my comment above and it was split into two lines... is the behaviour different in READMEs?

I _was_ sure! :-D

I just created a new test project and this is the contents of my README.md file:

# test
Just a test project

abc
def

Here's a screen grab of how it appears on github:

readme md

Ah, this probably has to do with https://githubengineering.com/a-formal-spec-for-github-markdown/

@jgm Maybe there should be a new extension flag? e.g. markdown_github_commonmark

Related stackoverflow question: http://stackoverflow.com/questions/24575680/new-lines-inside-paragraph-in-readme-md

The non-linebreaking behavior can be forced by using markdown_github-hard_line_breaks.

You're both right. GitHub has two Markdown modes, one for long-form documents like READMEs and one for short things like issue coments. In issue comments, a line break is treated as a hard line break. In README, wikis, etc., it is treated as a space as in regular Markdown.

People often get confused by this. [And it has nothing to do with CommonMark; now that GitHub is using CommonMark, they're still locally adding the hard line breaks extension in issue comments.]

We had to choose one for the default in markdown_github, so we chose +hard_line_breaks, but perhaps that is not the best decision, since pandoc is probably most often used for long-form documents. I'd be open to changing this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinushey picture kevinushey  路  79Comments

stepht picture stepht  路  54Comments

jgm picture jgm  路  62Comments

jgm picture jgm  路  117Comments

jgm picture jgm  路  266Comments