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:
@@ -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.
|
||||||
@@ -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: {
|
||||||
|
|||||||
Reference in New Issue
Block a user