11ty/eleventy-plugin-syntaxhighlight

Unsupported Languages cause Build Failures

Navigatron opened this issue · 3 comments

Situation

I have code blocks in my markdown, like the one below:

```sh
echo "Hello!"
```

"sh" is used here purely for the sake of example - I have 400+ pages of content that I'm in the process of migrating, with much more esoterically-tagged code blocks.

Result

Since "sh" is not a valid Prism language, Prism prints a warning. This causes eleventy to stop the build.

[11ty] Problem writing Eleventy templates:
[11ty] 1. Having trouble rendering liquid template ./source/content/xxxxx/xxxxx.md (via TemplateContentRenderError)
[11ty] 2. "sh" is not a valid Prism.js language for eleventy-plugin-syntaxhighlight (via Error)
[11ty] Wrote 0 files in 1.06 seconds (v1.0.1)

Expected Behavior

If a code block uses a language that isn't recognized, I would prefer if that code block were simply not highlighted at all (or treated as plain text) rather than the entire site failing to build.

Just to add another use-case:
I want to add eleventy-charts to my blog, and I also useeleventy-plugin-syntaxhighlight.
Since eleventy-charts uses the same triple back-ticks for enclosing chart's data, I can't have both plug-ins running at the same time.

See potential fix in PR: #73

Shipping in 5.0.0, an errorOnInvalidLanguage: false option, the default will be to allow invalid languages—you will have to opt-in to throwing an error.