php-markdown icon indicating copy to clipboard operation
php-markdown copied to clipboard

Code blocks (three backticks) all go to single line

Open Mikaela opened this issue 10 years ago • 9 comments

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.

Mikaela avatar Mar 18 '15 19:03 Mikaela

@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.

michelf avatar Mar 18 '15 20:03 michelf

@michelf Markdown Extra

Kovah avatar Mar 18 '15 20:03 Kovah

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.

michelf avatar Mar 18 '15 20:03 michelf

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?

Kovah avatar Mar 19 '15 06:03 Kovah

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.

michelf avatar Mar 19 '15 10:03 michelf

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

Kovah avatar Mar 19 '15 15:03 Kovah

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.

Kovah avatar Mar 20 '15 15:03 Kovah

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

michelf avatar Mar 20 '15 15:03 michelf

Thank you!

Kovah avatar Mar 20 '15 16:03 Kovah