Skip to content

Commit ebab7f4

Browse files
committed
Shiki transformers
1 parent e3b292b commit ebab7f4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

assets/controllers/code_highlight_controller.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { Controller } from "@hotwired/stimulus"
22
import { codeToHtml } from 'https://esm.sh/[email protected]'
3+
import { transformerNotationDiff, transformerNotationHighlight } from 'https://esm.sh/@shikijs/[email protected]'
34
import { useIntersection } from 'stimulus-use'
45

5-
66
/* stimulusFetch: 'lazy' */
77
export default class extends Controller {
8-
const
98
connect() {
109
useIntersection(this)
11-
1210
}
1311

1412
async appear() {
@@ -21,6 +19,10 @@ export default class extends Controller {
2119
this.element.outerHTML = await codeToHtml(this.element.textContent, {
2220
lang: this.element.dataset.lang || 'plaintext',
2321
theme: 'one-dark-pro',
22+
transformers: [
23+
transformerNotationDiff(),
24+
transformerNotationHighlight(),
25+
]
2426
});
2527
}
2628
}

0 commit comments

Comments
 (0)