Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

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

@KiwiKilian

Description

@KiwiKilian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions