This commit is contained in:
jlkiri 2020-12-27 21:47:59 +09:00
parent 134c767484
commit 908a7bda9a
3 changed files with 171 additions and 173 deletions

View File

@ -12,7 +12,7 @@ function wait_highlight(...args) {
try {
const subChannel = new MessageChannel();
worker.postMessage({ signal, port: subChannel.port1, args }, [
subChannel.port1
subChannel.port1,
]);
Atomics.wait(signal, 0, 0);
return receiveMessageOnPort(subChannel.port2).message.result;

View File

@ -3,19 +3,17 @@ const shiki = require("shiki");
const path = require("path");
async function shiki_highlight(code, lang) {
const highlighter = await
shiki
.getHighlighter({
theme: 'nord',
const highlighter = await shiki.getHighlighter({
theme: "nord",
langs: [
{
id: "kdl",
scopeName: "source.kdl",
path: path.join(process.cwd(), "kdl.tmLanguage.json")
}
]
})
return highlighter.codeToHtml(code, lang)
path: path.join(process.cwd(), "kdl.tmLanguage.json"),
},
],
});
return highlighter.codeToHtml(code, lang);
}
parentPort.addListener("message", async ({ signal, port, args }) => {

View File

@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"comment":"Some of these patterns are taken straight from rust-analyzer: https://github.com/rust-lang/vscode-rust/blob/master/rust-analyzer/editors/code/rust.tmGrammar.json. Some was also taken from https://github.com/arm32x/vscode-sdlang/blob/master/syntaxes/sdlang.tmLanguage.json",
"comment": "Some of these patterns are taken straight from rust-analyzer: https://github.com/rust-lang/vscode-rust/blob/master/rust-analyzer/editors/code/rust.tmGrammar.json. Some was also taken from https://github.com/arm32x/vscode-sdlang/blob/master/syntaxes/sdlang.tmLanguage.json",
"name": "KDL",
"patterns": [
{