【发布时间】:2021-02-20 18:16:05
【问题描述】:
我在这里查看 Monaco Editor 的沙盒:https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages
我正在尝试支持以下案例:
"A single line quote"
"But also a slightly weird
multi line quote"
我需要同时支持这两种语言,因为我使用的语言同时支持这两种语言。现在,我设置的规则如下所示:
// Register a tokens provider for the language
monaco.languages.setMonarchTokensProvider('mySpecialLanguage', {
tokenizer: {
root: [
[/"(?:[^"\\]|\\.\n{0,})*"/gi, 'my-string'],
]
}
});
// Define a new theme that contains only rules that match this language
monaco.editor.defineTheme('myCoolTheme', {
base: 'vs',
inherit: false,
rules: [
{ token: 'my-string', foreground: '0000FF' },
]
});
问题是多行引号不起作用。我怀疑摩纳哥会逐行解析导致问题的文本/代码,但我肯定不能独自解决这个问题。 有没有我必须设置的标志或其他东西?
【问题讨论】: