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
130 stars 32 forks source link

After upgrading from 3.0.4 to 3.0.5: `TemplateContentRenderError` was thrown when building #44

Closed jouni-kantola closed 3 years ago

jouni-kantola commented 3 years ago

Issue

After upgrading eleventy-plugin-syntaxhighlight from 3.0.4 to 3.0.5, I'm getting the following error when building HTML templates with liquid:

> Having trouble rendering html template ./src/index.html

`TemplateContentRenderError` was thrown
> Having trouble compiling template ./src/index.html

`TemplateContentCompileError` was thrown
> Cannot read property 'parser' of undefined, file:./src/index.html, line:2

`ParseError` was thrown
> Cannot read property 'parser' of undefined

`TypeError` was thrown:
    TypeError: Cannot read property 'parser' of undefined
        at Object.parse (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/@11ty/eleventy-plugin-syntaxhighlight/src/LiquidHighlightTag.js:18:34)
        at Object.parse (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/liquidjs/dist/liquid.common.js:1876:22)
        at Object.construct (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/liquidjs/dist/liquid.common.js:1887:14)
        at parseTag (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/liquidjs/dist/liquid.common.js:2037:16)
        at parseToken (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/liquidjs/dist/liquid.common.js:2021:15)
        at Object.parse (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/liquidjs/dist/liquid.common.js:2012:22)
        at Object.parse$$1 [as parse] (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/liquidjs/dist/liquid.common.js:3420:24)
        at Liquid.compile (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/@11ty/eleventy/src/Engines/Liquid.js:199:29)
        at Html.compile (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/@11ty/eleventy/src/Engines/Html.js:11:29)
        at TemplateRender.getCompiledTemplate (/FAKE_PATH/eleventy-syntax-highlighting-bug/node_modules/@11ty/eleventy/src/TemplateRender.js:206:26)

Output previous version

With eleventy-plugin-syntaxhighlight@3.0.4:

$ eleventy
Writing _site/index.html from ./src/index.html.
Wrote 1 file in 0.09 seconds (v0.11.1)
✨  Done in 1.91s.

Repro

// package.json
{
  "name": "eleventy-syntax-highlighting-bug",
  "version": "1.0.0",
  "private": "true",
  "dependencies": {
    "@11ty/eleventy": "^0.11.1"
  },
  "scripts": {
    "build": "eleventy"
  },
  "devDependencies": {
    "@11ty/eleventy-plugin-syntaxhighlight": "3.0.5"
  }
}

// .eleventy.js
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");

module.exports = function (eleventyConfig) {
  eleventyConfig.addPlugin(syntaxHighlight);

  return {
    dir: {
      input: "src",
    },
  };
};

// ./src/index.html
<div>
    {% highlight js %}
        console.log("hello world")
    {% endhighlight %}
</div>
zachleat commented 3 years ago

Shipped a new 3.0.6 to fix this—sorry about that!

jouni-kantola commented 3 years ago

Yer fast, @zachleat 🚀 Works well now, thanks a bunch 👍

zachleat commented 3 years ago

Really hate regressions 😇 thanks for the report!