markdown-to-jsx
markdown-to-jsx copied to clipboard
Fenced code blocks are parsed as inline code if backticks are not preceded by two newlines
Fenced code blocks are parsed as inline code if backticks are not preceded by two newlines.
Example input:
const input = "Run the following commands and verify no results are returned:\n```\n# group\ngrep ^shadow:[^:]*:[^:]*:[^:]+ /etc/group\n# passwd\nawk -F: '($4 == \"<shadow-gid>\") { print }' /etc/passwd\n```"
Run the following commands and verify no results are returned:
```
# group
grep ^shadow:[^:]*:[^:]*:[^:]+ /etc/group
# passwd
awk -F: '($4 == "<shadow-gid>") { print }' /etc/passwd
```
Rendered output:
To get the expected output, an additional newline is needed before the triple backticks:
const input = "Run the following commands and verify no results are returned:\n\n```\n# group\ngrep ^shadow:[^:]*:[^:]*:[^:]+ /etc/group\n# passwd\nawk -F: '($4 == \"<shadow-gid>\") { print }' /etc/passwd\n```"
Run the following commands and verify no results are returned:
```
# group
grep ^shadow:[^:]*:[^:]*:[^:]+ /etc/group
# passwd
awk -F: '($4 == "<shadow-gid>") { print }' /etc/passwd
```
Rendered output:
This behavior is unexpected since Github's markdown compiler seems to only require one newline before the triple backticks. Though they do recommend blank lines before and after code blocks for readability purposes.
Actually I think this may have been previously reported: https://github.com/probablyup/markdown-to-jsx/issues/267