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

Adjacent code blocks get merged #317

Closed
egrimley opened this issue Dec 21, 2019 · 1 comment
Closed

Adjacent code blocks get merged #317

egrimley opened this issue Dec 21, 2019 · 1 comment

Comments

@egrimley
Copy link

Adjacent code blocks get merged:

$ printf '```\naa\n```\n```\nbb\n```' | cmark -t html
<pre><code>aa
</code></pre>
<pre><code>bb
</code></pre>
$ printf '```\naa\n```\n```\nbb\n```' | cmark -t commonmark | cmark -t html
<pre><code>aa

bb
</code></pre>

Parenthetical remark: This doesn't happen with single-character code blocks because of the logic at commonmark.c:294:

$ printf '```\n1\n```' | cmark -t commonmark
``` 
1
```
$ printf '```\n12\n```' | cmark -t commonmark
    12

An easy way to fix this would be to delete about 10 lines from commonmark.c and render all code blocks without indentation.

Personally I prefer not to use indentation for code blocks. One could argue that it's better because it lets one copy-paste the code more easily. I'm not using indentation in this text box.

@jgm
Copy link
Member

jgm commented Dec 21, 2019

I agree, it probably makes sense to switch to using fenced code blocks in the commonmark renderer.

@jgm jgm closed this as completed in 77f7e7a Dec 21, 2019
jgm added a commit that referenced this issue Dec 21, 2019
This solves problems with adjacent code blocks being
merged.
QuietMisdreavus pushed a commit to swiftlang/swift-cmark that referenced this issue Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants