2025-01-17 03:41:52 +08:00
|
|
|
The Language API provides functions for parsing code in various programming languages and listing supported languages.
|
|
|
|
|
|
|
|
## Language Operations
|
|
|
|
|
2025-02-06 17:04:45 +08:00
|
|
|
### language.parseLanguage(language, code)
|
2025-01-17 03:41:52 +08:00
|
|
|
Parses a piece of code using any of the supported SilverBullet languages.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
```lua
|
|
|
|
local code = [[
|
|
|
|
function hello() {
|
|
|
|
console.log("Hello, world!");
|
|
|
|
}
|
|
|
|
]]
|
|
|
|
|
2025-02-06 17:04:45 +08:00
|
|
|
local tree = language.parseLanguage("javascript", [[
|
2025-01-17 03:41:52 +08:00
|
|
|
function hello() {
|
|
|
|
console.log("Hello, world!");
|
|
|
|
}
|
|
|
|
]])
|
|
|
|
print("Parsed syntax tree:", tree)
|
|
|
|
```
|
|
|
|
|
2025-02-06 17:04:45 +08:00
|
|
|
### language.listLanguages()
|
2025-01-17 03:41:52 +08:00
|
|
|
Lists all supported languages in fenced code blocks.
|
|
|
|
|
|
|
|
Example:
|
2025-02-06 17:04:45 +08:00
|
|
|
${language.listLanguages()}
|