diff --git a/packages/shaku-code-annotate-shiki-transformer/CHANGELOG.md b/packages/shaku-code-annotate-shiki-transformer/CHANGELOG.md index e214d7e..ac993f8 100644 --- a/packages/shaku-code-annotate-shiki-transformer/CHANGELOG.md +++ b/packages/shaku-code-annotate-shiki-transformer/CHANGELOG.md @@ -1,5 +1,11 @@ # shaku-code-annotate +## 0.2.1 + +### Patch Changes + +- hotfix for the language alias + ## 0.2.0 ### Minor Changes diff --git a/packages/shaku-code-annotate-shiki-transformer/package.json b/packages/shaku-code-annotate-shiki-transformer/package.json index 18ea8cb..9353134 100644 --- a/packages/shaku-code-annotate-shiki-transformer/package.json +++ b/packages/shaku-code-annotate-shiki-transformer/package.json @@ -1,6 +1,6 @@ { "name": "shaku-code-annotate-shiki-transformer", - "version": "0.2.0", + "version": "0.2.1", "dependencies": { "@types/hast": "^3.0.4", "shaku-code-annotate-core": "^0.10.0", diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/__snapshots__/codeToHtml.test.ts.snap b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/__snapshots__/codeToHtml.test.ts.snap index c230423..5192e2e 100644 --- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/__snapshots__/codeToHtml.test.ts.snap +++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/__snapshots__/codeToHtml.test.ts.snap @@ -1,25 +1,25 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`codeToHtml() + raw HTML 1`] = `"
function ChatRoom({ roomId }) {  const [serverUrl, setServerUrl] = useState('https://localhost:1234');  //       ^  // [<a href=\\"https:jser.dev\\">jser.dev</a>]  useEffect(() => {     // (                                                     )        const connection = createConnection(serverUrl, roomId);     // (1                )        connection.connect();      	return () => {           //(2                    )             connection.disconnect();  	};   //(3                 )  }, [serverUrl, roomId]);}
"`; +exports[`codeToHtml() + raw HTML 1`] = `"
function ChatRoom({ roomId }) {  const [serverUrl, setServerUrl] = useState('https://localhost:1234');

jser.dev

useEffect(() => { const connection = createConnection(serverUrl, roomId); connection.connect(); return () => { connection.disconnect(); }; }, [serverUrl, roomId]);}
"`; -exports[`codeToHtml() + raw HTML 2`] = `"
function hello() {  //        ^!  //    [Hello world!]!  //        ^  //    [Shaku <b>Shaku</b>]  const blog = \\"https://jser.dev\\"}  
"`; +exports[`codeToHtml() + raw HTML 2`] = `"
function hello() {  //        ^  //    [Hello world!]

Shaku Shaku

const blog = \\"https://jser.dev\\"}
"`; -exports[`codeToHtml() + raw HTML 3`] = `"
function useSomeEffect({blog}) {  useEffect(() => {    //  do some stuff      // @fold start      return () => {        // @highlight        location.href = 'https://jser.dev'      }      // @fold ^    }, [blog])}  
"`; +exports[`codeToHtml() + raw HTML 3`] = `"
function useSomeEffect({blog}) {  useEffect(() => {    //  do some stuff
{...} return () => { location.href = 'https://jser.dev' }
}, [blog])}
"`; -exports[`codeToHtml() + raw HTML 4`] = `"
// @class abc h123// @highlightfunction useSomeEffect({blog}) {  useEffect(() => {      return () => {        location.href = 'https://jser.dev'      }    }, [blog])}  
"`; +exports[`codeToHtml() + raw HTML 4`] = `"
function useSomeEffect({blog}) {  useEffect(() => {      return () => {        location.href = 'https://jser.dev'      }    }, [blog])}  
"`; -exports[`codeToHtml() + raw HTML 5`] = `"
function useSomeEffect({blog}) {  useEffect(() => {    // @data a=1      return () => {        // @data a-b-c=1-2-3 beg-1=hello-2        location.href = 'https://jser.dev'      }    }, [blog])}  
"`; +exports[`codeToHtml() + raw HTML 5`] = `"
function useSomeEffect({blog}) {  useEffect(() => {      return () => {        location.href = 'https://jser.dev'      }    }, [blog])}  
"`; -exports[`codeToHtml() + raw HTML 6`] = `"
  function useSomeEffect({blog}) {    // @cut v    useEffect(() => {        return () => {          // @cut ^          location.href = 'https://jser.dev'          // @cut start        }      }, [blog])      // @cut end    // @cut    // a comment to cut  }    
"`; +exports[`codeToHtml() + raw HTML 6`] = `"
  function useSomeEffect({blog}) {          location.href = 'https://jser.dev'  }    
"`; -exports[`codeToHtml() 1`] = `"
function ChatRoom({ roomId }) {  const [serverUrl, setServerUrl] = useState('https://localhost:1234');  //       ^  // [<a href=\\"https:jser.dev\\">jser.dev</a>]  useEffect(() => {     // (                                                     )        const connection = createConnection(serverUrl, roomId);     // (1                )        connection.connect();      	return () => {           //(2                    )             connection.disconnect();  	};   //(3                 )  }, [serverUrl, roomId]);}
"`; +exports[`codeToHtml() 1`] = `"
function ChatRoom({ roomId }) {  const [serverUrl, setServerUrl] = useState('https://localhost:1234');
&lt;p&gt;jser.dev&lt;/p&gt;
useEffect(() => { const connection = createConnection(serverUrl, roomId); connection.connect(); return () => { connection.disconnect(); }; }, [serverUrl, roomId]);}
"`; -exports[`codeToHtml() 2`] = `"
function hello() {  //        ^!  //    [Hello world!]!  //        ^  //    [Shaku <b>Shaku</b>]  const blog = \\"https://jser.dev\\"}  
"`; +exports[`codeToHtml() 2`] = `"
function hello() {  //        ^  //    [Hello world!]
&lt;p&gt;Shaku Shaku&lt;/p&gt;
const blog = \\"https://jser.dev\\"}
"`; -exports[`codeToHtml() 3`] = `"
function useSomeEffect({blog}) {  useEffect(() => {    //  do some stuff      // @fold start      return () => {        // @highlight        location.href = 'https://jser.dev'      }      // @fold ^    }, [blog])}  
"`; +exports[`codeToHtml() 3`] = `"
function useSomeEffect({blog}) {  useEffect(() => {    //  do some stuff
{...} return () => { location.href = 'https://jser.dev' }
}, [blog])}
"`; -exports[`codeToHtml() 4`] = `"
// @class abc h123// @highlightfunction useSomeEffect({blog}) {  useEffect(() => {      return () => {        location.href = 'https://jser.dev'      }    }, [blog])}  
"`; +exports[`codeToHtml() 4`] = `"
function useSomeEffect({blog}) {  useEffect(() => {      return () => {        location.href = 'https://jser.dev'      }    }, [blog])}  
"`; -exports[`codeToHtml() 5`] = `"
function useSomeEffect({blog}) {  useEffect(() => {    // @data a=1      return () => {        // @data a-b-c=1-2-3 beg-1=hello-2        location.href = 'https://jser.dev'      }    }, [blog])}  
"`; +exports[`codeToHtml() 5`] = `"
function useSomeEffect({blog}) {  useEffect(() => {      return () => {        location.href = 'https://jser.dev'      }    }, [blog])}  
"`; -exports[`codeToHtml() 6`] = `"
  function useSomeEffect({blog}) {    // @cut v    useEffect(() => {        return () => {          // @cut ^          location.href = 'https://jser.dev'          // @cut start        }      }, [blog])      // @cut end    // @cut    // a comment to cut  }    
"`; +exports[`codeToHtml() 6`] = `"
  function useSomeEffect({blog}) {          location.href = 'https://jser.dev'  }    
"`; diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/codeToHtml.test.ts b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/codeToHtml.test.ts index d275b50..a7e002e 100644 --- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/codeToHtml.test.ts +++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/codeToHtml.test.ts @@ -1,12 +1,4 @@ import { expect, test } from "vitest"; -import { getShakuHighlighters } from "../getHighlighters"; -import rehypeShiki from "@shikijs/rehype"; -import rehypeStringify from "rehype-stringify"; -import remarkParse from "remark-parse"; -import remarkRehype from "remark-rehype"; -import { unified } from "unified"; -import shakuCodeAnnotateShikiTransformer from ".."; -import * as shiki from "shiki"; import { fetchProcessor } from "./util"; const snippets = [ diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/objc/output.txt b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/objc/output.txt index 9992546..8110f44 100644 --- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/objc/output.txt +++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/objc/output.txt @@ -1 +1 @@ -
#import <Foundation/Foundation.h>// @highlight// This is a single-line comment// ------//  ^// [Hello World!]
\ No newline at end of file +
#import <Foundation/Foundation.h>// This is a single-line comment
------

Hello World!

\ No newline at end of file diff --git a/packages/shaku-code-annotate-shiki-transformer/src/commentPatterns.ts b/packages/shaku-code-annotate-shiki-transformer/src/commentPatterns.ts index 8d89120..4b7373a 100644 --- a/packages/shaku-code-annotate-shiki-transformer/src/commentPatterns.ts +++ b/packages/shaku-code-annotate-shiki-transformer/src/commentPatterns.ts @@ -42,7 +42,9 @@ export const commentPatterns: Record = { awk: PatternHash, ballerina: PatternDoubleSlash, batch: PatternBatch, + bat: PatternBatch, berry: PatternHash, + be: PatternHash, bicep: PatternDoubleSlash, blade: /^(?\s*)(?\{\{\-\-)(?.*)(?\-\-\}\})$/, @@ -61,13 +63,18 @@ export const commentPatterns: Record = { dart: PatternDoubleSlash, dax: PatternDoubleSlash, dockerfile: PatternHash, + docker: PatternHash, "dream-maker": PatternDoubleSlash, elixir: PatternHash, elm: PatternDoubleDash, erb: /^(?\s*)(?\<%#)(?.*)(?%\>)$/, erlang: PatternDoublePercentage, + erl: PatternDoublePercentage, + fish: PatternHash, "f#": PatternDoubleSlash, + fsharp: PatternDoubleSlash, + fs: PatternDoubleSlash, "git-commit": PatternHash, glsl: PatternDoubleSlash, gnuplot: PatternHash, @@ -76,15 +83,19 @@ export const commentPatterns: Record = { hack: PatternDoubleSlash, haml: /^(?\s*)(?-#)(?.*)$/, handlebars: PatternHBS, + hbs: PatternHBS, haskell: PatternDoubleDash, + hs: PatternDoubleDash, hcl: PatternHash, hlsl: PatternDoubleSlash, html: PatternXML, cpp: PatternDoubleSlash, "c#": PatternDoubleSlash, + cs: PatternDoubleSlash, go: PatternDoubleSlash, java: PatternDoubleSlash, javascript: PatternJSWithJSX, + js: PatternJSWithJSX, imba: PatternHash, ini: PatternSemiColon, properties: PatternHash, @@ -107,6 +118,7 @@ export const commentPatterns: Record = { make: PatternHash, makefile: PatternHash, markdown: PatternXML, + md: PatternXML, marko: PatternXML, mdx: /^(?\s*)(?\{\/\*)(?.*)(?\*\/\})$/, mermaid: /^(?\s*)(?%%)(?.*)$/, @@ -114,6 +126,8 @@ export const commentPatterns: Record = { nim: PatternHash, nix: PatternHash, "objective-c": PatternDoubleSlash, + objc: PatternDoubleSlash, + "objective-cpp": PatternDoubleSlash, ocaml: /^(?\s*)(?\(\*)(?.*)(?\*\))$/, @@ -122,6 +136,7 @@ export const commentPatterns: Record = { perl: PatternHash, powerquery: PatternDoubleSlash, powershell: PatternHash, + ps: PatternHash, prisma: PatternDoubleSlash, prolog: PatternPercentage, proto: PatternDoubleSlash, @@ -149,10 +164,13 @@ export const commentPatterns: Record = { sparql: PatternHash, stata: PatternAsterisk, stylus: PatternDoubleSlash, + styl: PatternDoubleSlash, svelte: PatternSFC, python: PatternHash, ruby: PatternHash, + rb: PatternHash, rust: PatternDoubleSlash, + rs: PatternDoubleSlash, sql: PatternDoubleDash, "system-verilog": PatternDoubleSlash, tcl: PatternHash, @@ -163,6 +181,7 @@ export const commentPatterns: Record = { swift: PatternDoubleSlash, twig: /^(?\s*)(?\{#)(?.*)(?#\})$/, typescript: PatternJSWithJSX, + ts: PatternJSWithJSX, vb: /^(?\s*)(?\')(?.*)$/, verilog: PatternDoubleSlash, vhdl: PatternDoubleDash, @@ -171,12 +190,14 @@ export const commentPatterns: Record = { vue: PatternSFC, wasm: PatternDoubleSemiColon, wenyan: /^(?\s*)(?注曰。)(?.*)$/, + 文言: /^(?\s*)(?注曰。)(?.*)$/, wgsl: PatternDoubleSlash, wolfram: /^(?\s*)(?\(\*)(?.*)(?\*\))$/, xml: PatternXML, xsl: PatternXML, yaml: PatternHash, + yml: PatternHash, zenscript: PatternDoubleSlash, jison: PatternDoubleSlash, "ssh-config": PatternHash, diff --git a/packages/shaku-code-annotate-shiki-transformer/src/defaultCode.ts b/packages/shaku-code-annotate-shiki-transformer/src/defaultCode.ts index a638af0..a4ed711 100644 --- a/packages/shaku-code-annotate-shiki-transformer/src/defaultCode.ts +++ b/packages/shaku-code-annotate-shiki-transformer/src/defaultCode.ts @@ -1530,10 +1530,10 @@ export const supportedLangs = [ "astro", "awk", "ballerina", - // "bat", + "bat", "batch", "berry", - // "be", + "be", // "bibtex", "bicep", "blade", @@ -1551,25 +1551,25 @@ export const supportedLangs = [ "cpp", "crystal", "c#", - // "cs", + "cs", "css", "cue", "d", "dart", "dax", // "diff", // nothing to test - // "docker", + "docker", "dockerfile", "dream-maker", "elixir", "elm", "erb", "erlang", - // "erl", + "erl", "fish", - // "fsharp", + "fsharp", "f#", - // "fs", + "fs", // "gdresource", // "gdscript", // "gdshader", @@ -1584,9 +1584,9 @@ export const supportedLangs = [ "hack", "haml", "handlebars", - // "hbs", + "hbs", "haskell", - // "hs", + "hs", "hcl", "hlsl", "html", @@ -1619,7 +1619,7 @@ export const supportedLangs = [ "make", "makefile", "markdown", - // "md", + "md", "marko", "matlab", "mdx", @@ -1628,7 +1628,7 @@ export const supportedLangs = [ "nim", "nix", "objective-c", - // "objc", + "objc", "objective-cpp", "ocaml", "pascal", @@ -1638,7 +1638,7 @@ export const supportedLangs = [ // "postcss", "powerquery", "powershell", - // "ps", + "ps", // "ps1", "prisma", "prolog", @@ -1657,9 +1657,9 @@ export const supportedLangs = [ "riscv", // "rst", "ruby", - // "rb", + "rb", "rust", - // "rs", + "rs", "sas", "sass", "scala", @@ -1680,7 +1680,7 @@ export const supportedLangs = [ "ssh-config", "stata", "stylus", - // "styl", + "styl", "svelte", "swift", "system-verilog", @@ -1692,7 +1692,7 @@ export const supportedLangs = [ "turtle", "twig", "typescript", - // "ts", + "ts", // "v", "vb", // "cmd", @@ -1705,12 +1705,12 @@ export const supportedLangs = [ "vue", "wasm", "wenyan", - // "文言", + "文言", "wgsl", "wolfram", "xml", "xsl", "yaml", - // "yml", + "yml", "zenscript", ] as const; diff --git a/packages/shaku-code-annotate-shiki-transformer/src/index.ts b/packages/shaku-code-annotate-shiki-transformer/src/index.ts index 8ec9983..5b36227 100644 --- a/packages/shaku-code-annotate-shiki-transformer/src/index.ts +++ b/packages/shaku-code-annotate-shiki-transformer/src/index.ts @@ -58,6 +58,7 @@ type ShakuUpdatesForLine = Map>; type Options = { /** * whether or not to escape the annotation + * use it if you want to support markdown in annotation * @default false */ useDangerousRawHtml?: boolean; diff --git a/packages/shaku-code-annotate-shiki-transformer/tsconfig.json b/packages/shaku-code-annotate-shiki-transformer/tsconfig.json index b4b1c16..601d774 100644 --- a/packages/shaku-code-annotate-shiki-transformer/tsconfig.json +++ b/packages/shaku-code-annotate-shiki-transformer/tsconfig.json @@ -8,7 +8,7 @@ "skipLibCheck": true, "noEmit": true, "strict": true, - "target": "ES2015" + "target": "ES2018" }, "exclude": ["node_modules"] }