svg preview renderer

This commit is contained in:
zack 2024-10-26 21:41:22 -04:00
parent 43a8412f06
commit faa9599849
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35
29 changed files with 1027 additions and 254 deletions

View file

@ -9,11 +9,10 @@ const CodeBlockHook = {
this.el.dataset.highlightedLines || "[]",
);
console.log(code);
console.log("language", language);
const lines = code.split("\n");
console.log(lines.length, lines);
// Convert line numbers to decorations
const decorations = highlightedLines
.map((line) => {
@ -40,7 +39,16 @@ const CodeBlockHook = {
codeToHtml(code, {
lang: language,
theme: "catppuccin-mocha",
decorations,
transformers: [
{
line(node, line) {
node.properties["data-line"] = line;
if (highlightedLines.includes(line)) {
this.addClassToHast(node, "highlighted");
}
},
},
],
}).then((html) => {
console.log(html);