Add syntax highlighting for code snippets
This commit is contained in:
parent
dbaa63a575
commit
064bb0b0ad
|
@ -106,7 +106,7 @@ packages:
|
||||||
remark-parse: 11.0.0
|
remark-parse: 11.0.0
|
||||||
remark-rehype: 11.1.0
|
remark-rehype: 11.1.0
|
||||||
remark-smartypants: 2.1.0
|
remark-smartypants: 2.1.0
|
||||||
shiki: 1.2.3
|
shiki: 1.2.4
|
||||||
unified: 11.0.4
|
unified: 11.0.4
|
||||||
unist-util-remove-position: 5.0.0
|
unist-util-remove-position: 5.0.0
|
||||||
unist-util-visit: 5.0.0
|
unist-util-visit: 5.0.0
|
||||||
|
@ -885,7 +885,7 @@ packages:
|
||||||
resolution: {integrity: sha512-LWgttQTUrIPE1X+Lya1qFWiX47tH2AS2hkbj/cZoWkdiSjn6zUvtTypK/2Xn6Rgn6z6ClzpgHvkXRqFn7nAB4A==}
|
resolution: {integrity: sha512-LWgttQTUrIPE1X+Lya1qFWiX47tH2AS2hkbj/cZoWkdiSjn6zUvtTypK/2Xn6Rgn6z6ClzpgHvkXRqFn7nAB4A==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@expressive-code/core': 0.33.5
|
'@expressive-code/core': 0.33.5
|
||||||
shiki: 1.2.3
|
shiki: 1.2.4
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@expressive-code/plugin-text-markers@0.33.5:
|
/@expressive-code/plugin-text-markers@0.33.5:
|
||||||
|
@ -1141,8 +1141,8 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@shikijs/core@1.2.3:
|
/@shikijs/core@1.2.4:
|
||||||
resolution: {integrity: sha512-SM+aiQVaEK2P53dEcsvhq9+LJPr0rzwezHbMQhHaSrPN4OlOB4vp1qTdhVEKfMg6atdq8s9ZotWW/CSCzWftwg==}
|
resolution: {integrity: sha512-ClaUWpt8oTzjcF0MM1P81AeWyzc1sNSJlAjMG80CbwqbFqXSNz+NpQVUC0icobt3sZn43Sn27M4pHD/Jmp3zHw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@types/acorn@4.0.6:
|
/@types/acorn@4.0.6:
|
||||||
|
@ -1487,7 +1487,7 @@ packages:
|
||||||
rehype: 13.0.1
|
rehype: 13.0.1
|
||||||
resolve: 1.22.8
|
resolve: 1.22.8
|
||||||
semver: 7.6.0
|
semver: 7.6.0
|
||||||
shiki: 1.2.3
|
shiki: 1.2.4
|
||||||
string-width: 7.1.0
|
string-width: 7.1.0
|
||||||
strip-ansi: 7.1.0
|
strip-ansi: 7.1.0
|
||||||
tsconfck: 3.0.3(typescript@5.4.3)
|
tsconfck: 3.0.3(typescript@5.4.3)
|
||||||
|
@ -4033,10 +4033,10 @@ packages:
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/shiki@1.2.3:
|
/shiki@1.2.4:
|
||||||
resolution: {integrity: sha512-+v7lO5cJMeV2N2ySK4l+51YX3wTh5I49SLjAOs1ch1DbUfeEytU1Ac9KaZPoZJCVBGycDZ09OBQN5nbcPFc5FQ==}
|
resolution: {integrity: sha512-Q9n9jKiOjJCRPztA9POn3/uZXNySHDNKAsPNpmtHDcFyi6ZQhx5vQKZW3Nhrwn8TWW3RudSRk66zqY603EZDeg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@shikijs/core': 1.2.3
|
'@shikijs/core': 1.2.4
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/signal-exit@3.0.7:
|
/signal-exit@3.0.7:
|
||||||
|
|
|
@ -49,7 +49,8 @@ fn main() {
|
||||||
This code defines a function called `main` that will be executed every tick.
|
This code defines a function called `main` that will be executed every tick.
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
ShulkerScript always requires a `main` function to be present in the code.
|
ShulkerScript always requires at least one function annotated with `tick`, `load` or `deobfuscate`.
|
||||||
|
Otherwise no `.mcfunction` files will be generated.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### Annotations
|
### Annotations
|
||||||
|
@ -110,7 +111,7 @@ In most cases, you can use [literal commands](#literal-commands) instead of the
|
||||||
The `lua` keyword is used to embed Lua code in your ShulkerScript code. It can be combined with the `run` keyword to include the result of the Lua code in the output.
|
The `lua` keyword is used to embed Lua code in your ShulkerScript code. It can be combined with the `run` keyword to include the result of the Lua code in the output.
|
||||||
```shulkerscript
|
```shulkerscript
|
||||||
run lua() {
|
run lua() {
|
||||||
// Lua code goes here
|
-- Lua code goes here
|
||||||
return "Hello, Lua!";
|
return "Hello, Lua!";
|
||||||
}
|
};
|
||||||
```
|
```
|
|
@ -16,7 +16,7 @@ Your Lua code should return a string value when used in combination with the run
|
||||||
## Syntax
|
## Syntax
|
||||||
```shulkerscript
|
```shulkerscript
|
||||||
run lua() {
|
run lua() {
|
||||||
// Lua code goes here
|
-- Lua code goes here
|
||||||
return "Hello, Lua!";
|
return "Hello, Lua!";
|
||||||
}
|
};
|
||||||
```
|
```
|
|
@ -1,20 +1,10 @@
|
||||||
import type { PluginShikiOptions } from "@astrojs/starlight/expressive-code";
|
import type { PluginShikiOptions } from "@astrojs/starlight/expressive-code";
|
||||||
|
import { shulkerscriptGrammar } from "./shulkerscript-grammar";
|
||||||
|
|
||||||
const config: PluginShikiOptions = {
|
const config: PluginShikiOptions = {
|
||||||
langs: [
|
langs: [
|
||||||
/*{
|
shulkerscriptGrammar,
|
||||||
name: 'shulkerscript',
|
],
|
||||||
aliases: ['shu'],
|
|
||||||
displayName: 'ShulkerScript',
|
|
||||||
fileTypes: ['shu'],
|
|
||||||
scopeName: 'source.shulkerscript',
|
|
||||||
patterns: [
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}*/
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
|
||||||
|
export const shulkerscriptGrammar = {
|
||||||
|
name: "shulkerscript",
|
||||||
|
aliases: ["shu"],
|
||||||
|
displayName: "ShulkerScript",
|
||||||
|
fileTypes: ["shu"],
|
||||||
|
scopeName: "source.shulkerscript",
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
include: "#functionContents",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
include: "#functionDeclaration",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
include: "#functionAnnotation",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
repository: {
|
||||||
|
// Groupings
|
||||||
|
functionContents: {
|
||||||
|
patterns: [
|
||||||
|
{ include: "#docComment" },
|
||||||
|
{ include: "#lineComment" },
|
||||||
|
{ include: "#blockComment" },
|
||||||
|
{ include: "#commandLiteral" },
|
||||||
|
{ include: "#lua" },
|
||||||
|
{ include: "#groupBlock" },
|
||||||
|
{ include: "#stringLiteral" },
|
||||||
|
{ include: "#binaryOperator" },
|
||||||
|
{ include: "#ifKeyword" },
|
||||||
|
{ include: "#elseKeyword" },
|
||||||
|
{ include: "#runKeyword" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
// Components
|
||||||
|
lineComment: {
|
||||||
|
name: "comment.line.shulkerscript",
|
||||||
|
match: "//.*$",
|
||||||
|
},
|
||||||
|
blockComment: {
|
||||||
|
name: "comment.block.shulkerscript",
|
||||||
|
begin: "/\\*",
|
||||||
|
end: "\\*/",
|
||||||
|
},
|
||||||
|
docComment: {
|
||||||
|
name: "comment.documentation.shulkerscript",
|
||||||
|
match: "///.*$",
|
||||||
|
},
|
||||||
|
functionDeclaration: {
|
||||||
|
name: "entity.name.function.shulkerscript",
|
||||||
|
begin: "^\\s*(fn)\\s+(\\w+)\\(\\s*\\)\\s*{",
|
||||||
|
end: "}",
|
||||||
|
captures: {
|
||||||
|
1: {
|
||||||
|
name: "keyword.control.function.shulkerscript",
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
name: "entity.name.function.shulkerscript",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
patterns: [{ include: "#functionContents" }],
|
||||||
|
},
|
||||||
|
functionAnnotation: {
|
||||||
|
name: "entity.annotation.function.shulkerscript",
|
||||||
|
match: '(#\\[)(\\w+)(?:\\s*=\\s*"[^"]+")?(\\])',
|
||||||
|
captures: {
|
||||||
|
1: {
|
||||||
|
name: "keyword.operator.annotation.shulkerscript",
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
name: "entity.annotation.function.shulkerscript",
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
name: "keyword.operator.annotation.shulkerscript",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
binaryOperator: {
|
||||||
|
name: "punctuation.operator.binary.shulkerscript",
|
||||||
|
match: "(&&|\\|\\|)",
|
||||||
|
},
|
||||||
|
ifKeyword: {
|
||||||
|
name: "keyword.control.if.shulkerscript",
|
||||||
|
match: "\\bif\\b",
|
||||||
|
},
|
||||||
|
elseKeyword: {
|
||||||
|
name: "keyword.control.else.shulkerscript",
|
||||||
|
match: "\\belse\\b",
|
||||||
|
},
|
||||||
|
runKeyword: {
|
||||||
|
name: "keyword.control.run.shulkerscript",
|
||||||
|
match: "\\brun\\b",
|
||||||
|
},
|
||||||
|
commandLiteral: {
|
||||||
|
name: "string.commandliteral.shulkerscript",
|
||||||
|
match: "^\\s*(/\\w+)(.*)$",
|
||||||
|
captures: {
|
||||||
|
1: {
|
||||||
|
name: "keyword.operator.literalcommand.shulkerscript",
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
name: "string.command.shulkerscript",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
stringLiteral: {
|
||||||
|
name: "string.quoted.double.shulkerscript",
|
||||||
|
begin: '"',
|
||||||
|
end: '"',
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
name: "constant.character.escape.shulkerscript",
|
||||||
|
match: "\\\\.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
lua: {
|
||||||
|
name: "entity.lua.shulkerscript",
|
||||||
|
begin: "(lua)\\s*\\(\\s*\\)\\s*{",
|
||||||
|
end: "}",
|
||||||
|
beginCaptures: {
|
||||||
|
1: {
|
||||||
|
name: "keyword.control.lua.shulkerscript",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
patterns: [{ include: "source.lua" }],
|
||||||
|
},
|
||||||
|
groupBlock: {
|
||||||
|
name: "entity.group.shulkerscript",
|
||||||
|
begin: "^\\s*(group)\\s*{",
|
||||||
|
end: "}",
|
||||||
|
captures: {
|
||||||
|
1: {
|
||||||
|
name: "keyword.control.group.shulkerscript",
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
name: "entity.name.group.shulkerscript",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
patterns: [{ include: "#functionContents" }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in New Issue