chore(code): reintegrate batch syntax

This commit is contained in:
Elian Doran 2025-05-11 10:38:36 +03:00
parent 01f02b736c
commit efc08a61ef
No known key found for this signature in database
2 changed files with 30 additions and 33 deletions

View File

@ -1,8 +1,14 @@
// Source: https://github.com/deathau/cm-editor-syntax-highlight-obsidian/issues/27#issuecomment-1340586596
(() => {
var varsAndArgsRegex = /(%[0-9]|%~\S+|%\S+%)/;
/**
* @module
*
* Ported to CodeMirror 6 from https://github.com/deathau/cm-editor-syntax-highlight-obsidian/issues/27#issuecomment-1340586596
*/
CodeMirror.defineSimpleMode("batch", {
import { simpleMode } from "@codemirror/legacy-modes/mode/simple-mode";
const varsAndArgsRegex = /(%[0-9]|%~\S+|%\S+%)/;
export const batch = simpleMode({
start: [
{ //comment
regex: /(rem|::)(?:\s.*|$)/i,
@ -39,13 +45,4 @@
next: "start"
}
]
});
CodeMirror.defineMIME("application/x-bat", "batch");
CodeMirror.modeInfo.push({
ext: [ "bat", "cmd" ],
mime: "application/x-bat",
mode: "batch",
name: "Batch file"
});
})();
});

View File

@ -6,7 +6,7 @@ const byMimeType: Record<string, (() => Promise<StreamParser<unknown>>) | null>
"text/x-ttcn-asn": async () => (await import('@codemirror/legacy-modes/mode/ttcn')).ttcn,
"application/x-aspx": null,
"text/x-asterisk": async () => (await import('@codemirror/legacy-modes/mode/asterisk')).asterisk,
"application/x-bat": null,
"application/x-bat": async () => (await import("./languages/batch.js")).batch,
"text/x-brainfuck": async () => (await import('@codemirror/legacy-modes/mode/brainfuck')).brainfuck,
"text/x-csrc": async () => (await import('@codemirror/legacy-modes/mode/clike')).c,
"text/x-csharp": async () => (await import('@codemirror/legacy-modes/mode/clike')).csharp,