add syntax highlight for pipes and pipe breaks
This commit is contained in:
parent
c3bd64e204
commit
df19c98e9f
|
@ -249,12 +249,13 @@ export class SlashCommandParser {
|
||||||
end: /\||$|:}/,
|
end: /\||$|:}/,
|
||||||
contains: [],
|
contains: [],
|
||||||
};
|
};
|
||||||
const KEYWORD = {
|
const IMPORT = {
|
||||||
scope: 'command',
|
scope: 'command',
|
||||||
begin: /\/(import)/,
|
begin: /\/(import)/,
|
||||||
beginScope: 'keyword',
|
beginScope: 'keyword',
|
||||||
end: /\||$|(?=:})/,
|
end: /\||$|(?=:})/,
|
||||||
excludeEnd: true,
|
excludeEnd: false,
|
||||||
|
returnEnd: true,
|
||||||
contains: [],
|
contains: [],
|
||||||
};
|
};
|
||||||
const LET = {
|
const LET = {
|
||||||
|
@ -265,20 +266,24 @@ export class SlashCommandParser {
|
||||||
1: 'variable',
|
1: 'variable',
|
||||||
},
|
},
|
||||||
end: /\||$|:}/,
|
end: /\||$|:}/,
|
||||||
|
excludeEnd: false,
|
||||||
|
returnEnd: true,
|
||||||
contains: [],
|
contains: [],
|
||||||
};
|
};
|
||||||
const SETVAR = {
|
const SETVAR = {
|
||||||
begin: /\/(setvar|setglobalvar)\s+/,
|
begin: /\/(setvar|setglobalvar)\s+/,
|
||||||
beginScope: 'variable',
|
beginScope: 'variable',
|
||||||
end: /\||$|:}/,
|
end: /\||$|:}/,
|
||||||
excludeEnd: true,
|
excludeEnd: false,
|
||||||
|
returnEnd: true,
|
||||||
contains: [],
|
contains: [],
|
||||||
};
|
};
|
||||||
const GETVAR = {
|
const GETVAR = {
|
||||||
begin: /\/(getvar|getglobalvar)\s+/,
|
begin: /\/(getvar|getglobalvar)\s+/,
|
||||||
beginScope: 'variable',
|
beginScope: 'variable',
|
||||||
end: /\||$|:}/,
|
end: /\||$|:}/,
|
||||||
excludeEnd: true,
|
excludeEnd: false,
|
||||||
|
returnEnd: true,
|
||||||
contains: [],
|
contains: [],
|
||||||
};
|
};
|
||||||
const RUN = {
|
const RUN = {
|
||||||
|
@ -297,7 +302,8 @@ export class SlashCommandParser {
|
||||||
begin: /\/\S+/,
|
begin: /\/\S+/,
|
||||||
beginScope: 'title.function',
|
beginScope: 'title.function',
|
||||||
end: /\||$|(?=:})/,
|
end: /\||$|(?=:})/,
|
||||||
excludeEnd: true,
|
excludeEnd: false,
|
||||||
|
returnEnd: true,
|
||||||
contains: [], // defined later
|
contains: [], // defined later
|
||||||
};
|
};
|
||||||
const CLOSURE = {
|
const CLOSURE = {
|
||||||
|
@ -318,6 +324,16 @@ export class SlashCommandParser {
|
||||||
begin: /{{/,
|
begin: /{{/,
|
||||||
end: /}}/,
|
end: /}}/,
|
||||||
};
|
};
|
||||||
|
const PIPEBREAK = {
|
||||||
|
beginScope: 'pipebreak',
|
||||||
|
begin: /\|\|/,
|
||||||
|
end: '',
|
||||||
|
};
|
||||||
|
const PIPE = {
|
||||||
|
beginScope: 'pipe',
|
||||||
|
begin: /\|/,
|
||||||
|
end: '',
|
||||||
|
};
|
||||||
BLOCK_COMMENT.contains.push(
|
BLOCK_COMMENT.contains.push(
|
||||||
BLOCK_COMMENT,
|
BLOCK_COMMENT,
|
||||||
);
|
);
|
||||||
|
@ -329,7 +345,7 @@ export class SlashCommandParser {
|
||||||
MACRO,
|
MACRO,
|
||||||
CLOSURE,
|
CLOSURE,
|
||||||
);
|
);
|
||||||
KEYWORD.contains.push(
|
IMPORT.contains.push(
|
||||||
hljs.BACKSLASH_ESCAPE,
|
hljs.BACKSLASH_ESCAPE,
|
||||||
NAMED_ARG,
|
NAMED_ARG,
|
||||||
NUMBER,
|
NUMBER,
|
||||||
|
@ -374,7 +390,7 @@ export class SlashCommandParser {
|
||||||
BLOCK_COMMENT,
|
BLOCK_COMMENT,
|
||||||
COMMENT,
|
COMMENT,
|
||||||
ABORT,
|
ABORT,
|
||||||
KEYWORD,
|
IMPORT,
|
||||||
NAMED_ARG,
|
NAMED_ARG,
|
||||||
NUMBER,
|
NUMBER,
|
||||||
MACRO,
|
MACRO,
|
||||||
|
@ -385,22 +401,26 @@ export class SlashCommandParser {
|
||||||
COMMAND,
|
COMMAND,
|
||||||
'self',
|
'self',
|
||||||
hljs.QUOTE_STRING_MODE,
|
hljs.QUOTE_STRING_MODE,
|
||||||
|
PIPEBREAK,
|
||||||
|
PIPE,
|
||||||
);
|
);
|
||||||
hljs.registerLanguage('stscript', ()=>({
|
hljs.registerLanguage('stscript', ()=>({
|
||||||
case_insensitive: false,
|
case_insensitive: false,
|
||||||
keywords: ['|'],
|
keywords: [],
|
||||||
contains: [
|
contains: [
|
||||||
hljs.BACKSLASH_ESCAPE,
|
hljs.BACKSLASH_ESCAPE,
|
||||||
BLOCK_COMMENT,
|
BLOCK_COMMENT,
|
||||||
COMMENT,
|
COMMENT,
|
||||||
ABORT,
|
ABORT,
|
||||||
KEYWORD,
|
IMPORT,
|
||||||
RUN,
|
RUN,
|
||||||
LET,
|
LET,
|
||||||
GETVAR,
|
GETVAR,
|
||||||
SETVAR,
|
SETVAR,
|
||||||
COMMAND,
|
COMMAND,
|
||||||
CLOSURE,
|
CLOSURE,
|
||||||
|
PIPEBREAK,
|
||||||
|
PIPE,
|
||||||
],
|
],
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1583,6 +1583,13 @@ body[data-stscript-style] .hljs.language-stscript {
|
||||||
color: var(--ac-style-color-keyword);
|
color: var(--ac-style-color-keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hljs-pipe {
|
||||||
|
color: var(--ac-style-color-punctuation);
|
||||||
|
}
|
||||||
|
.hljs-pipebreak {
|
||||||
|
color: var(--ac-style-color-type);
|
||||||
|
}
|
||||||
|
|
||||||
.hljs-closure {
|
.hljs-closure {
|
||||||
>.hljs-punctuation {
|
>.hljs-punctuation {
|
||||||
color: var(--ac-style-color-punctuation);
|
color: var(--ac-style-color-punctuation);
|
||||||
|
|
Loading…
Reference in New Issue