1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-12-02 20:22:52 +00:00

fix codeblocks breaking files

This commit is contained in:
Laura
2025-11-17 23:25:05 +01:00
parent dfecceae93
commit d04a855d8a
2 changed files with 24 additions and 21 deletions

View File

@@ -1,10 +1,8 @@
To emit files (no tools), output blocks exactly as: To emit files (no tools), output blocks exactly as:
```
FILE "name" FILE "name"
<<CONTENT>> <<CONTENT>>
<contents> your contents here
<<END>> <<END>>
```
Repeat per file, no code fences, markdown or extra text. Repeat per file, no code fences, markdown or extra text.

View File

@@ -22,25 +22,30 @@
return; return;
} }
if (type !== "code") {
return; if (type === "code") {
if (text.trim().match(/^§\|FILE\|\d+\|§$/gm)) {
token.type = "text";
return;
}
const lang = token.lang || "plaintext";
let code;
if (lang && hljs.getLanguage(lang)) {
code = hljs.highlight(text.trim(), {
language: lang,
});
} else {
code = hljs.highlightAuto(text.trim());
}
token.escaped = true;
token.lang = code.language || "plaintext";
token.text = code.value;
} }
const lang = token.lang || "plaintext";
let code;
if (lang && hljs.getLanguage(lang)) {
code = hljs.highlight(text.trim(), {
language: lang,
});
} else {
code = hljs.highlightAuto(text.trim());
}
token.escaped = true;
token.lang = code.language || "plaintext";
token.text = code.value;
}, },
renderer: { renderer: {