docs: baked a lot of API docs

This commit is contained in:
Zef Hemel
2026-08-06 14:48:21 +02:00
parent 9b4de31ca3
commit 754e8525b9
36 changed files with 4888 additions and 49 deletions
+129 -1
View File
@@ -9,4 +9,132 @@ references:
The Markdown API provides functions for parsing and rendering Markdown content.
${spacelua.renderApiDocumentation("markdown")}
<!--#lua spacelua.renderApiDocumentation("markdown") -->
## markdown.bakeSections
`markdown.bakeSections(text, pageName?)`
Re-evaluates all baked Lua sections in Markdown text; sections that error or only render as HTML are left unchanged.
**Parameters:**
- `text` (`string`) — Markdown containing baked sections.
- `pageName?` (`string`) — Page used as currentPage during evaluation.
**Returns:**
- `string` — Markdown with updated baked section bodies.
**Example:**
```lua
local text = "Total: <!--#lua 1 + 2 -->\nold\n<!-- /lua -->"
print(markdown.bakeSections(text))
```
## markdown.expandMarkdown
`markdown.expandMarkdown(text, options?)`
`markdown.expandMarkdown(tree, options?)`
Expands Markdown transclusions, Lua directives, and task references.
**Parameters:**
- `textOrTree` — Markdown text or parsed tree.
- `options?` (`table`) — Expansion switches: expandTransclusions, expandLuaDirectives, and rewriteTasks; all default to true.
**Returns:**
- Value — Expanded text or tree, matching the input form.
**Example:**
```lua
local expanded = markdown.expandMarkdown("This is some Lua: ${1 + 2}")
```
## markdown.markdownToHtml
`markdown.markdownToHtml(text, options?)`
Renders Markdown text to HTML.
**Parameters:**
- `text` (`string`) — Markdown source.
- `options?` (`table`) — HTML rendering options.
**Returns:**
- `string` — Rendered HTML.
**Example:**
```lua
local html = markdown.markdownToHtml("# Title")
```
## markdown.objectsToTable
`markdown.objectsToTable(data, options?)`
Formats a list of objects as a Markdown table.
**Parameters:**
- `data` (`table`) — Rows to render.
- `options?` (`table`) — Optional renderCell callback.
**Returns:**
- `string` — Markdown table.
**Example:**
```lua
local tableText = markdown.objectsToTable({{name = "Pete", age = 20}})
```
## markdown.parseMarkdown
`markdown.parseMarkdown(text)`
Parses Markdown text into a syntax tree.
**Parameters:**
- `text` (`string`) — Markdown source.
**Returns:**
- `table` — Parsed Markdown tree.
**Example:**
```lua
local tree = markdown.parseMarkdown("# Title")
```
## markdown.renderParseTree
`markdown.renderParseTree(tree)`
Renders a Markdown syntax tree back to source text.
**Parameters:**
- `tree` (`table`) — Markdown syntax tree.
**Returns:**
- `string` — Rendered Markdown.
**Example:**
```lua
local tree = markdown.parseMarkdown("# Title")
print(markdown.renderParseTree(tree))
```
<!--/lua-->