smalldocs.shortcodes
Quarto’s shortcodes that make sense without Pandoc:
include, meta, var, env, pagebreak, kbd, video, lipsum and placeholder.lookup
lookup(data: dict, key: str) -> objectFind a dotted key in nested options.
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
dict | required | Nested options |
key |
str | required | A dotted key, such as author.name |
| returns | object | The value, or None |
arguments
arguments(text: str) -> tuple[list[str], dict[str, str]]Split a shortcode’s arguments, with quotes as in a shell.
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
str | required | What follows the shortcode’s name, such as Shift-Ctrl-P mac=Shift-Command-P |
| returns | tuple[list[str], dict[str, str]] | The plain arguments, and the key=value ones |
kbd
kbd(text: str, count: list[int]) -> strShow keys to press, as Quarto’s kbd shortcode, with the keys for each system in the title.
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
str | required | The arguments: the keys, then mac=, win= and linux= for each system |
count |
list[int] | required | Not used |
| returns | str | Quarto’s markup: a <kbd>, and the keys again for screen readers |
video
video(text: str, count: list[int]) -> strEmbed a video, as Quarto’s video shortcode.
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
str | required | The arguments: the address or the file, then title, width, height, aspect-ratio and start |
count |
list[int] | required | How many videos the page has so far; this one adds one |
| returns | str | Quarto’s markup: an embedded player for YouTube, Vimeo and Brightcove, else a <video> |
lipsum
lipsum(text: str, count: list[int]) -> strWrite placeholder text, as Quarto’s lipsum shortcode.
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
str | required | The arguments: how many paragraphs, such as 2, or a range, such as 1-3 |
count |
list[int] | required | Not used |
| returns | str | Paragraphs of placeholder text |
placeholder
placeholder(text: str, count: list[int]) -> strDraw a grey box of a given size, as Quarto’s placeholder shortcode, without a call to a web service.
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
str | required | The arguments: the width, and the height, which is the width when it is missing |
count |
list[int] | required | Not used |
| returns | str | An <img> of a grey box, drawn as SVG in the page |
expand
expand(text: str, here: Path, root: Path, meta: dict, warn: list[str], depth: int = 0, count: list[int] | None = None) -> strReplace the shortcodes in a page, outside code blocks.
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
str | required | Markdown that may hold shortcodes |
here |
Path | required | The file it comes from, for include paths |
root |
Path | required | The project’s root, for _variables.yml and paths from / |
meta |
dict | required | The page’s options, for meta |
warn |
list[str] | required | Where to note a shortcode that smalldocs does not know |
depth |
int | 0 |
How deep in includes we are, to stop a loop |
count |
list[int] | None | None |
How many videos the page has so far, shared with its includes |
| returns | str | The text with the shortcodes replaced; code blocks are left alone |