Skip to content

feat: shiki transformers support #19

@aidenybai

Description

@aidenybai

Shiki has the transformers API and the @shikijs/transformers package. These transformers contain a lot of useful utilities (such as highlight) that would be amazing to have. I wrote a pnpm patch to try and add it, but it didn't seem to work:

/patches/[email protected]

diff --git a/dist/core.mjs b/dist/core.mjs
index 13943e61abccc2b932fe40314014c3ceb856ceaf..b0f25036385759029c5f70ef4743d6f1eb1df7e6 100644
--- a/dist/core.mjs
+++ b/dist/core.mjs
@@ -1,6 +1,7 @@
 import { diff } from 'diff-match-patch-es';
 import { hash } from 'ohash';
 
+import {transformerNotationHighlight} from "@shikijs/transformers"
 function createMagicMoveMachine(codeToKeyedTokens2, options = {}) {
   const EMPTY = toKeyedTokens("", []);
   let previous = EMPTY;
@@ -30,7 +31,7 @@ function createMagicMoveMachine(codeToKeyedTokens2, options = {}) {
   };
 }
 function codeToKeyedTokens(highlighter, code, options, lineNumbers = false) {
-  const result = highlighter.codeToTokens(code, options);
+  const result = highlighter.codeToTokens(code,  {... options, transformers: [transformerNotationHighlight()] });
   return {
     ...toKeyedTokens(
       code,

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions