silverbullet/website/API/markdown.md

32 lines
654 B
Markdown
Raw Normal View History

2025-01-17 03:41:52 +08:00
# Markdown API
The Markdown API provides functions for parsing and rendering Markdown content.
## Markdown Operations
### markdown.parseMarkdown(text)
2025-01-17 03:41:52 +08:00
Parses a piece of markdown text into a ParseTree.
Example:
```lua
local text = [[
# Hello World
This is a **bold** statement.
]]
local tree = markdown.parseMarkdown(text)
2025-01-17 03:41:52 +08:00
print("Parsed markdown tree:", tree)
```
### markdown.renderParseTree(tree)
2025-01-17 03:41:52 +08:00
Renders a ParseTree back to markdown text.
Example:
```lua
local text = "# Title\n\nSome text"
local tree = markdown.parseMarkdown(text)
2025-01-17 03:41:52 +08:00
-- Modify tree if needed
local rendered = markdown.renderParseTree(tree)
2025-01-17 03:41:52 +08:00
print("Rendered markdown:", rendered)