11ty / eleventy-plugin-syntaxhighlight

A pack of Eleventy plugins for syntax highlighting in Markdown, Liquid, and Nunjucks templates.
https://www.11ty.dev/docs/plugins/syntaxhighlight/
MIT License
129 stars 32 forks source link

Confusing error on unrecognized language #18

Closed porglezomp closed 4 years ago

porglezomp commented 5 years ago

If I use an unrecognized syntax, for instance:

File index.md:

```asdfl

Then the error is confusing.

Language does not exist asdfl Problem writing Eleventy templates: (more in DEBUG output)

Having trouble rendering njk (and markdown) template ./index.md

TemplateContentRenderError was thrown

Cannot read property 'rest' of undefined

The first line mentions that the language doesn't exist, but I didn't realize for quite a while that that warning was the cause of the later fatal error.

Expected Behavior: Unrecognized languages should give a warning and then simply fail to highlight that syntax.

zachleat commented 4 years ago

That console.warn Language does not exist asdfl actually comes from Prism, unfortunately. https://github.com/PrismJS/prism/issues/2145

But we can clean up the error message.