Skip to content

Whitespace in fenced code info string breaks rendering #1314

Closed

Description

@camwiegert

Describe the bug

When there is whitespace in the info string of a fenced code block, like so:

```html foo

...the block is not parsed as a code block. It appears to be rendered as a paragraph:

<p>```html foo</p>

To Reproduce

Steps to reproduce the behavior:

  1. Add a whitespace character in the info string of a fenced code block.
  2. Render with the default renderer.

Expected behavior

When there is whitespace in the info string, GFM appears to use the first word as the language and ignore the rest. (As demonstrated here) I would expect Marked to do the same by default and pass the entire info string to a custom renderer.

Thank you! 👋

Activity

  1. camwiegert commented on Aug 1, 2018

    @camwiegert
    Author

    For reference, here is the GFM spec on info strings.

  2. UziTech commented on Aug 1, 2018

    @UziTech
    Member
  3. added
    L2 - annoying
    on Aug 1, 2018
  4. Feder1co5oave commented on Dec 10, 2018

    @Feder1co5oave
    Contributor

    #1387 returns this:

    bin/marked
    ```html foo
    ^D
    <pre><code class="language-html"></code></pre>
    

    which seems correct

  5. camwiegert commented on Dec 10, 2018

    @camwiegert
    Author

    Thanks for addressing this! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    L2 - annoying

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions