michelf / php-markdown

Parser for Markdown and Markdown Extra derived from the original Markdown.pl by John Gruber.
http://michelf.ca/projects/php-markdown/
Other
3.42k stars 530 forks source link

Code blocks (three backticks) all go to single line #197

Open Mikaela opened 9 years ago

Mikaela commented 9 years ago

For example:


```
ufw allow 113
ufw allow 631
ufw allow 100XX
ufw limit 22
ufw enable
```

from https://wiki.mikaela.info/Me%20%28Mikaela%29/New%C2%A0systems.md becomes

ufw allow 113 ufw allow 631 ufw allow 100XX ufw limit 22 ufw enable

while it should become

ufw allow 113
ufw allow 631
ufw allow 100XX
ufw limit 22
ufw enable

this can be also reproduced with most of other markdown files on wiki.mikaela.info this site was removed.

This issue was originally reported at https://github.com/victorstanciu/Wikitten/issues/48 and was told to be moved here in https://github.com/victorstanciu/Wikitten/issues/48#issuecomment-83134632.

michelf commented 9 years ago

@Kovah Is Wikitten using the Markdown or the MarkdownExtra parser? Fenced code blocks are not a base feature of Markdown and are only available with Markdown Extra.

Kovah commented 9 years ago

@michelf Markdown Extra

michelf commented 9 years ago

For all I can see, the above parses correctly with Markdown Extra. This can be tested on the PHP Markdown Dingus. Perhaps the input above isn't the actual input given to Markdown Extra or perhaps Wikitten is using a very old version. I can't open the .md file linked to test the whole file on the Dingus, so there's not really anything I can investigate right now.

Kovah commented 9 years ago

Here's one: https://devwiki.invoiceplane.com/v2/Index.md The "Then run the following commands:" should be one command per line but it's a single line.

So you think this is a problem with how Wikitten handles the Markdown?

michelf commented 9 years ago

If I copy-paste the Markdown source for that document in the Dingus, set the filter to PHP Markdown Extra, and hit Convert, I get a correctly formatted code block. So it should work.

But I see you're using PHP Markdown Extra 1.2.6. Backtick fenced code blocks were added in 1.2.8. That's why it doesn't work. You can use a tilde ~~~ fence instead, or update the version of PHP Markdown.

Kovah commented 9 years ago

Thanks for your help, will create a pull request for that! :tada:

Kovah commented 9 years ago

I updated Wikitten to the latest Markdown Extra library and tried to use ~~~ for codeblocks but they won't be rendered... Is there a setting that needs to be enabled??? :worried:

See https://github.com/victorstanciu/Wikitten/pull/53 for the corresponding pull request.

michelf commented 9 years ago

Here you need to use /Michelf/MarkdownExtra if you want to use the Markdown Extra parser.

Kovah commented 9 years ago

Thank you!