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

Unsupported Languages cause Build Failures #70

Closed Navigatron closed 1 year ago

Navigatron commented 2 years ago

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.
yehudab commented 2 years ago

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.

yehudab commented 2 years ago

See potential fix in PR: #73

zachleat commented 1 year ago

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.