fix(frontend): 修复 aardio 注释着色、代码行距与折叠 hydration
注释不再被运算符拆开;去掉 grid 行 min-height;挂载后再折叠以避免 SSR/CSR 不一致。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import type { LanguageRegistration } from "shiki";
|
||||
|
||||
/**
|
||||
* aardio TextMate grammar(对齐官方 Prism / 用户提供的 highlight.js 规则):
|
||||
* aardio TextMate grammar(对齐官方 Prism / highlight.js 规则):
|
||||
* https://www.aardio.com/zh-cn/docs/js/prism.js
|
||||
*/
|
||||
export const aardioGrammar: LanguageRegistration = {
|
||||
name: "aardio",
|
||||
scopeName: "source.aardio",
|
||||
// 勿把 name 自身再写进 aliases,否则 Shiki 报 Circular alias `aardio -> aardio`
|
||||
// 勿把 name 自身再写进 aliases,否则 Shiki 报 Circular alias
|
||||
patterns: [
|
||||
{ include: "#block-comment" },
|
||||
{ include: "#line-comment" },
|
||||
@@ -25,9 +25,9 @@ export const aardioGrammar: LanguageRegistration = {
|
||||
repository: {
|
||||
"block-comment": {
|
||||
name: "comment.block.aardio",
|
||||
begin: "/\\*+",
|
||||
end: "\\*+/",
|
||||
patterns: [{ include: "self" }],
|
||||
// 用明确的 /* ... */,不要 include self(会在注释内再次匹配运算符)
|
||||
begin: "/\\*",
|
||||
end: "\\*/",
|
||||
},
|
||||
"line-comment": {
|
||||
name: "comment.line.double-slash.aardio",
|
||||
@@ -76,17 +76,16 @@ export const aardioGrammar: LanguageRegistration = {
|
||||
keywords: {
|
||||
name: "keyword.control.aardio",
|
||||
match:
|
||||
"\\b(?:begin|end|if|lambda|λ|else|elseif|class|function|return|while|do|namespace|select|case|catch|try|for|in|this|global|self|owner|var|def|and|not|or|break|continue|import|with|ctor|eval|type|assert|assert2|assertf|error|rget|callex|errput|loadcode|dumpcode|collectgarbage|call|invoke|tostring|topointer|tonumber|sleep|execute|setlocale|setprivilege|loadcodex|reduce|switch)\\b",
|
||||
"\\b(?:begin|end|if|lambda|\\u03BB|else|elseif|class|function|return|while|do|namespace|select|case|catch|try|for|in|this|global|self|owner|var|def|and|not|or|break|continue|import|with|ctor|eval|type|assert|assert2|assertf|error|rget|callex|errput|loadcode|dumpcode|collectgarbage|call|invoke|tostring|topointer|tonumber|sleep|execute|setlocale|setprivilege|loadcodex|reduce|switch)\\b",
|
||||
},
|
||||
literals: {
|
||||
name: "constant.language.aardio",
|
||||
match: "\\b(?:true|false|null)\\b",
|
||||
},
|
||||
"function-call": {
|
||||
// 排除关键字,避免 if( 被当成函数
|
||||
name: "entity.name.function.aardio",
|
||||
match:
|
||||
"\\b(?!(?:begin|end|if|lambda|λ|else|elseif|class|function|return|while|do|namespace|select|case|catch|try|for|in|this|global|self|owner|var|def|null|and|not|or|break|continue|import|with|ctor|eval|type|assert|assert2|assertf|error|rget|callex|errput|loadcode|dumpcode|collectgarbage|call|invoke|tostring|topointer|tonumber|sleep|execute|setlocale|setprivilege|loadcodex|reduce|switch|true|false)\\b)[_$[:alpha:]][_$[:alnum:]]*(?=\\s*\\()",
|
||||
"\\b(?!(?:begin|end|if|lambda|\\u03BB|else|elseif|class|function|return|while|do|namespace|select|case|catch|try|for|in|this|global|self|owner|var|def|null|and|not|or|break|continue|import|with|ctor|eval|type|assert|assert2|assertf|error|rget|callex|errput|loadcode|dumpcode|collectgarbage|call|invoke|tostring|topointer|tonumber|sleep|execute|setlocale|setprivilege|loadcodex|reduce|switch|true|false)\\b)[_$A-Za-z][_$A-Za-z0-9]*(?=\\s*\\()",
|
||||
},
|
||||
numbers: {
|
||||
patterns: [
|
||||
@@ -110,8 +109,9 @@ export const aardioGrammar: LanguageRegistration = {
|
||||
},
|
||||
operators: {
|
||||
name: "keyword.operator.aardio",
|
||||
// / 与 * 用前瞻避开注释分隔符 /* */,避免把注释拆成运算符
|
||||
match:
|
||||
"\\.\\.|--|\\+\\+|\\*\\*=?|&&=?|\\|\\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|[~:?]",
|
||||
"\\.\\.|--|\\+\\+|\\*\\*=?|&&=?|\\|\\|=?|[!=]==|<<=?|>>>?=?|\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=|[=!<>]=?|[+\\-~%?:]|\\^|&|\\||/(?!\\*)|\\*(?!/)",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user