Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin breaks with @11ty/eleventy@3.0.0 #193

Open
KiwiKilian opened this issue Dec 26, 2023 · 0 comments
Open

Plugin breaks with @11ty/eleventy@3.0.0 #193

KiwiKilian opened this issue Dec 26, 2023 · 0 comments

Comments

@KiwiKilian
Copy link

KiwiKilian commented Dec 26, 2023

Loading with deasync breaks in @11ty/eleventy@3.0.0. With the new ESM support by Eleventy the plugin could boil down to this:

import { setupForFile, transformAttributesToHTML } from 'remark-shiki-twoslash';

/**
 * @param {*} eleventyConfig
 * @param {import("shiki-twoslash").UserConfigSettings} options
 */
export default async function (eleventyConfig, options = {}) {
  const { highlighters } = await setupForFile(options);

  eleventyConfig.addMarkdownHighlighter((code, lang, fence) => {
    code = code.replace(/\r?\n$/, ''); // strip trailing newline fed during code block parsing
    return transformAttributesToHTML(code, [lang, fence].join(' '), highlighters, options);
  });
}

Note this would drop support for versions below 11ty/eleventy@3.0.0, therefore I'm not sure if I should create a PR? Otherwise #189 might be a solution, independent of the Eleventy version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant