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/[email protected] #193

Open
KiwiKilian opened this issue Dec 26, 2023 · 1 comment
Open

Plugin breaks with @11ty/[email protected] #193

KiwiKilian opened this issue Dec 26, 2023 · 1 comment

Comments

@KiwiKilian
Copy link

KiwiKilian commented Dec 26, 2023

Loading with deasync breaks in @11ty/[email protected]. 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/[email protected], therefore I'm not sure if I should create a PR? Otherwise #189 might be a solution, independent of the Eleventy version.

@olets
Copy link

olets commented Oct 26, 2024

Thanks for sharing that solution. I've made a fork which uses it to support Eleventy 3: @olets/eleventy-plugin-shiki-twoslash. My fork also has the latest Shiki themes and languages.

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

2 participants