Skip to content

Should ignore lang string after the first space #98

@tolmasky

Description

@tolmasky

If you have a code fence like this:

```javascript more stuff
5 + 5
```

Most markdown interpreters simply ignore everything after the space and treat the syntax coloring based only on the first part. For example, if you view the source of this very comment, you'll see that the code fences below is "javascript test" and not just "javascript". This is very useful because it allows one to provide additional functionality. In particular, on the node site we are going to have javascript runkit to turn on "runnability" on certain code blocks ( nodejs/node#22831 ). The fix is very simple, just changing:

if (node.lang && SUPPORTED_SYNTAXES.indexOf(node.lang.toLowerCase()) >= 0) {

to:

if (node.lang && SUPPORTED_SYNTAXES.indexOf(node.lang.split(" ")[0].toLowerCase()) >= 0) {

I'm happy to submit this change but wanted to run it by everyone here first.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions