From 5d7a9205df3c20f5b6a0464f3e1123394a7ca23a Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 6 Feb 2026 01:07:43 +0800 Subject: Updated code highlight for doc site. [skip CI] --- doc/docs/.vitepress/config.mts | 16 +- doc/docs/.vitepress/grammars/moonscript.tmLanguage | 263 -------- .../.vitepress/grammars/moonscript.tmLanguage.json | 149 ----- .../.vitepress/grammars/yuescript.tmLanguage.json | 689 +++++++++++++++++++++ .../.vitepress/theme/components/YueCompiler.vue | 193 +++++- doc/docs/doc/destructuring-assignment.md | 2 +- doc/docs/doc/macro.md | 1 + doc/docs/zh/doc/destructuring-assignment.md | 2 +- doc/docs/zh/doc/macro.md | 1 + 9 files changed, 869 insertions(+), 447 deletions(-) delete mode 100644 doc/docs/.vitepress/grammars/moonscript.tmLanguage delete mode 100644 doc/docs/.vitepress/grammars/moonscript.tmLanguage.json create mode 100644 doc/docs/.vitepress/grammars/yuescript.tmLanguage.json (limited to 'doc') diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts index c672c7a..188c2fa 100644 --- a/doc/docs/.vitepress/config.mts +++ b/doc/docs/.vitepress/config.mts @@ -10,13 +10,13 @@ import darkPlus from '@shikijs/themes/dark-plus'; import lightPlus from '@shikijs/themes/light-plus'; const __dirname = dirname(fileURLToPath(import.meta.url)) -const moonscriptGrammarPath = resolve(__dirname, 'grammars/moonscript.tmLanguage.json') -const moonscriptGrammar = JSON.parse(readFileSync(moonscriptGrammarPath, 'utf-8')) -const moonscriptLanguage = { - ...moonscriptGrammar, - name: 'moonscript', - scopeName: 'source.moonscript', - aliases: ['yue', 'yuescript', 'moon'], +const yuescriptGrammarPath = resolve(__dirname, 'grammars/yuescript.tmLanguage.json') +const yuescriptGrammar = JSON.parse(readFileSync(yuescriptGrammarPath, 'utf-8')) +const yuescriptLanguage = { + ...yuescriptGrammar, + name: 'yuescript', + scopeName: 'source.yuescript', + aliases: ['yue'], } // Generate sidebar configuration function @@ -205,7 +205,7 @@ export default defineConfig({ }, markdown: { languages: [ - moonscriptLanguage, + yuescriptLanguage, ], theme: { light: lightPlus, diff --git a/doc/docs/.vitepress/grammars/moonscript.tmLanguage b/doc/docs/.vitepress/grammars/moonscript.tmLanguage deleted file mode 100644 index 2c041ba..0000000 --- a/doc/docs/.vitepress/grammars/moonscript.tmLanguage +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - comment - MoonScript Syntax: 0.0.1 - fileTypes - - moon - - - name - MoonScript - - patterns - - - captures - - 1 - - name - punctuation.definition.comment.lua - - - match - (--)(?!\[\[).*$\n? - name - comment.line.double-dash.lua - - - - - begin - ' - beginCaptures - - 0 - - name - punctuation.definition.string.begin.lua - - - end - ' - endCaptures - - 0 - - name - punctuation.definition.string.end.lua - - - name - string.quoted.single.lua - patterns - - - match - \\(\d{1,3}|.) - name - constant.character.escape.lua - - - - - - begin - " - beginCaptures - - 0 - - name - punctuation.definition.string.begin.lua - - - end - " - endCaptures - - 0 - - name - punctuation.definition.string.end.lua - - - name - string.quoted.double.lua - patterns - - - match - \\(\d{1,3}|.) - name - constant.character.escape.lua - - - - - - begin - (?<!--)\[(=*)\[ - beginCaptures - - 0 - - name - punctuation.definition.string.begin.lua - - - end - \]\1\] - endCaptures - - 0 - - name - punctuation.definition.string.end.lua - - - name - string.quoted.other.multiline.lua - - - - match - (?<![\d.])\s0x[a-fA-F\d]+|\b\d+(\.\d+)?([eE]-?\d+)?|\.\d+([eE]-?\d+)? - name - constant.numeric.lua - - - - name - support.constant - match - \b[A-Z]\w*\b(?!:) - - - - name - keyword.operator - match - =>|-> - - - - match - \b(and|or|not)\b - name - keyword.operator.lua - - - - match - [a-zA-Z_]\w*\s*(?=:) - name - entity.name.function - - - - match - \(|\) - name - entity.name.function - - - - match - \+|-|%|#|\*|\/|\^|==?|~=|!=|\\|:|,|;|\.|<=?|>=?|(?<!\.)\.{2}(?!\.) - name - keyword.operator.lua - - - - match - {|}|\[|\] - name - storage.modifier - - - - name - storage.type.class - match - \b(class|extends|super)\b - - - - name - keyword.control - match - \b(if|then|else|elseif|export|import|from|switch|when|with|using|do|for|in|while|return|local|unless|continue|break)\b - - - - name - variable.language - match - \b(self)\b - - - - name - variable.parameter - match - @@?[a-zA-Z_]\w*\b - - - - name - constant.language.nil - match - \b(nil)\b - - - - - match - \b(true|false)\b - name - constant.language.boolean - - - - match - (?<!\.|\\)\b(function|repeat|end)\b(?!\s*:) - name - invalid.illegal - - - - match - (?<![^.]\.|\\)\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\b - name - support.function.lua - - - - match - (?<![^.]\.|\\)\b(_G)\b - name - support.constant - - - - match - (?<![^.]\.|\\)\b(coroutine\.(create|resume|running|status|wrap|yield)|string\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)|table\.(concat|insert|maxn|remove|sort)|math\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?)|io\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\.(cpath|loaded|loadlib|path|preload|seeall)|debug\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|traceback))\b - name - support.function.library.lua - - - - - scopeName - source.moonscript - uuid - D363822C-639B-4450-A21A-F45643A6940F - - diff --git a/doc/docs/.vitepress/grammars/moonscript.tmLanguage.json b/doc/docs/.vitepress/grammars/moonscript.tmLanguage.json deleted file mode 100644 index 98a3dc9..0000000 --- a/doc/docs/.vitepress/grammars/moonscript.tmLanguage.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "comment": "MoonScript Syntax: 0.0.1", - "fileTypes": [ - "moon" - ], - "name": "MoonScript", - "patterns": [ - { - "captures": { - "1": { - "name": "punctuation.definition.comment.lua" - } - }, - "match": "(--)(?!\\[\\[).*$\\n?", - "name": "comment.line.double-dash.lua" - }, - { - "begin": "'", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.lua" - } - }, - "end": "'", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.lua" - } - }, - "name": "string.quoted.single.lua", - "patterns": [ - { - "match": "\\\\(\\d{1,3}|.)", - "name": "constant.character.escape.lua" - } - ] - }, - { - "begin": "\"", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.lua" - } - }, - "end": "\"", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.lua" - } - }, - "name": "string.quoted.double.lua", - "patterns": [ - { - "match": "\\\\(\\d{1,3}|.)", - "name": "constant.character.escape.lua" - } - ] - }, - { - "begin": "(?