Skip to content

Adjacent code blocks get merged #317

@egrimley

Description

@egrimley

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions