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 5192e2e..c230423 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');jser.dev
useEffect(() => { const connection = createConnection(serverUrl, roomId); connection.connect(); return () => { connection.disconnect(); }; }, [serverUrl, roomId]);}
"`;
+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 2`] = `"function hello() { // ^ // [Hello world!]Shaku Shaku
const blog = \\"https://jser.dev\\"}
"`;
+exports[`codeToHtml() + raw HTML 2`] = `"function hello() { // ^! // [Hello world!]! // ^ // [Shaku <b>Shaku</b>] const blog = \\"https://jser.dev\\"}
"`;
-exports[`codeToHtml() + raw HTML 3`] = `"function useSomeEffect({blog}) { useEffect(() => { // do some stuff }, [blog])}
"`;
+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 4`] = `"function useSomeEffect({blog}) { useEffect(() => { 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 5`] = `"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 6`] = `" function useSomeEffect({blog}) { location.href = 'https://jser.dev' }
"`;
+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() 1`] = `"function ChatRoom({ roomId }) { const [serverUrl, setServerUrl] = useState('https://localhost:1234');<p>jser.dev</p> useEffect(() => { const connection = createConnection(serverUrl, roomId); connection.connect(); return () => { connection.disconnect(); }; }, [serverUrl, roomId]);}
"`;
+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() 2`] = `"function hello() { // ^ // [Hello world!]<p>Shaku Shaku</p> const blog = \\"https://jser.dev\\"}
"`;
+exports[`codeToHtml() 2`] = `"function hello() { // ^! // [Hello world!]! // ^ // [Shaku <b>Shaku</b>] const blog = \\"https://jser.dev\\"}
"`;
-exports[`codeToHtml() 3`] = `"function useSomeEffect({blog}) { useEffect(() => { // do some stuff }, [blog])}
"`;
+exports[`codeToHtml() 3`] = `"function useSomeEffect({blog}) { useEffect(() => { // do some stuff // @fold start return () => { // @highlight location.href = 'https://jser.dev' } // @fold ^ }, [blog])}
"`;
-exports[`codeToHtml() 4`] = `"function useSomeEffect({blog}) { useEffect(() => { 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() 5`] = `"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() 6`] = `" function useSomeEffect({blog}) { location.href = 'https://jser.dev' }
"`;
+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 }
"`;
diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/liquid/output.txt b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/liquid/output.txt
index ced215f..9a48b35 100644
--- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/liquid/output.txt
+++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/liquid/output.txt
@@ -1 +1 @@
-This is a multi-line comment {% comment %}----------Hello World!
{% endcomment %}
\ No newline at end of file
+This is a multi-line comment {% comment %} ---------- ^ [Hello World!]{% endcomment %}
\ No newline at end of file
diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/mermaid/output.txt b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/mermaid/output.txt
index 0ace835..820a0d4 100644
--- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/mermaid/output.txt
+++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/mermaid/output.txt
@@ -1 +1 @@
-graph LR A[Start] --> B[Process] %% @highlight B --> C[Process] C --> D[End] %% ----- %% ^ %% [Hello Shaku!]
\ No newline at end of file
+graph LR A[Start] --> B[Process] B --> C[Process] C --> D[End]-----Hello Shaku!
\ No newline at end of file
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 8110f44..9992546 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>// This is a single-line comment------Hello World!
\ No newline at end of file
+#import <Foundation/Foundation.h>// @highlight// This is a single-line comment// ------// ^// [Hello World!]
\ No newline at end of file
diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/prolog/output.txt b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/prolog/output.txt
index 0f686a9..5a26cab 100644
--- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/prolog/output.txt
+++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/prolog/output.txt
@@ -1 +1 @@
-% Predicates for family relationships% @highlightparent(john, sarah).% -----% ^% [Hello World!]
\ No newline at end of file
+% Predicates for family relationshipsparent(john, sarah).-----Hello World!
\ No newline at end of file
diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/razor/output.txt b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/razor/output.txt
index 0ac4fd0..4de8a42 100644
--- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/razor/output.txt
+++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/razor/output.txt
@@ -1 +1 @@
-<h1>Welcome to our website!</h1> @{----Hello World!
}
\ No newline at end of file
+<h1>Welcome to our website!</h1> @{ // ---- // ^ //[Hello World!] }
\ No newline at end of file
diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/smalltalk/output.txt b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/smalltalk/output.txt
index f7f1531..86fd734 100644
--- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/smalltalk/output.txt
+++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/smalltalk/output.txt
@@ -1 +1 @@
-Object subclass: MyClass [ "This is a simple class named MyClass." | instanceVariable | MyClass class >> classMethod [ "This is a class method of MyClass." ^ 'Hello from class method!'-----Hello Shaku!
] MyClass >> instanceMethod [ "This is an instance method of MyClass." ^ 'Hello from instance method!' ]]
\ No newline at end of file
+Object subclass: MyClass [ "This is a simple class named MyClass." | instanceVariable | "@highlight" MyClass class >> classMethod [ "This is a class method of MyClass." ^ 'Hello from class method!' " -----" " ^ " " [Hello Shaku!]" ] MyClass >> instanceMethod [ "This is an instance method of MyClass." ^ 'Hello from instance method!' ]]
\ No newline at end of file
diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/stata/output.txt b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/stata/output.txt
index e991874..2e576e9 100644
--- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/stata/output.txt
+++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/stata/output.txt
@@ -1 +1 @@
-* @highlightuse "mydata.dta"------Hello Shaku!
\ No newline at end of file
+use "mydata.dta"------Hello Shaku!
\ No newline at end of file
diff --git a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/tsx/output.txt b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/tsx/output.txt
index e0c24a8..d6d42ec 100644
--- a/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/tsx/output.txt
+++ b/packages/shaku-code-annotate-shiki-transformer/src/__tests__/langs/tsx/output.txt
@@ -1 +1 @@
-const MyComponent: React.FC = () => { return ( {/* @highlight */} <div> {/* This is a comment inside JSX */} <h1>Hello, World!</h1>-----Hello World!
</div> );};
\ No newline at end of file
+const MyComponent: React.FC = () => { return ( <div> {/* This is a comment inside JSX */} <h1>Hello, World!</h1>-----Hello World!
</div> );};
\ 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
new file mode 100644
index 0000000..8d89120
--- /dev/null
+++ b/packages/shaku-code-annotate-shiki-transformer/src/commentPatterns.ts
@@ -0,0 +1,183 @@
+import { supportedLangs } from "./defaultCode";
+
+type Lang = (typeof supportedLangs)[number];
+
+const PatternAsterisk = /^(?