zakhenry/embedme

Language extension with metadata isn't parsed correctly

blu3r4y opened this issue · 0 comments

One can add metadata after the first word in the info string of a code fence.

```js startline=3
// file.js

Current Behavior

This isn't parsed correctly at the moment and produces the following error.

file.md#L10-L15 Unsupported file extension [js startline=3], supported extensions are [...], skipping code block

Expected Behavior

The CommonMark specification says the following on that:

An info string can be provided after the opening code fence. Although this spec doesn’t mandate any particular treatment of the info string, the first word is typically used to specify the language of the code block."

They also provide some examples - see here - where only the first word (here: "ruby") would be extracted from a code fence like that.

```    ruby startline=3 $%@#$
def foo(x)

Some frameworks rely on this metadata, e.g., reveal.js uses it for highlighting certain lines, see here.

Resolution

Only parse the first word and ignore metadata when identifying the extension.