Pandoc document conversion via Hot Box containers.
Convert between Markdown, HTML, PDF, DOCX, and many other formats using
pandoc in isolated containers. Input can be a hot:// file URL or inline
text; outputs are written to hot:// storage.
Quick Start
// Convert a stored Markdown file to HTML
out ::pandoc/convert("hot://docs/readme.md", {to: "html", from: "markdown"})
tap(out.url)
// Convert inline Markdown to HTML (nano box)
page ::pandoc/convert-text("# Title\\n\\nHello.", {to: "html", from: "markdown"})
tap(page.text)
// With explicit output path
out ::pandoc/convert("hot://docs/readme.md", {
to: "pdf",
from: "markdown",
output: "hot://docs/readme.pdf",
})
// Pandoc version
ver ::pandoc/version()
tap(ver.version)
Container Requirements
small
Values
DEFAULT_IMAGE
DEFAULT_IMAGE: Str "pandoc/core:3.8-alpine"
Functions
build-convert-args
fn (input-path: Str, output-path: Str, opts: ConvertOpts): Vec<Str>
Build pandoc CLI arguments: input, format flags, optional features, -o output.
Example
::pandoc/build-convert-args("/data/in.md", "/data/out.html", ::pandoc/ConvertOpts({from: "markdown", to: "html", toc: true}))
// ["/data/in.md", "-f", "markdown", "-t", "html", "--toc", "-o", "/data/out.html"]
build-version-args
fn (): Vec<Str>
Build pandoc --version arguments.
Example
::pandoc/build-version-args() // ["--version"]
convert
fn (input: Str, opts: ConvertOpts): Map
Convert a document stored at a hot:// URL using pandoc.
Returns {url: Str, format: Str} with the output file URL in Hot storage.
Example
out ::pandoc/convert("hot://uploads/notes.md", {
from: "markdown",
to: "html",
standalone: true,
toc: true,
})
out.url
out.format // "html"
small
convert-text
fn (text: Str, opts: ConvertOpts): Map
Convert inline document text (written to a temp file inside the box).
Returns {url: Str, format: Str, text: Str}. For text-oriented output
formats (html, markdown, latex, etc.), text contains the converted
document body; for binary outputs such as pdf or docx, text is empty.
Example
page ::pandoc/convert-text("# Hi\\n\\nThere.", {from: "markdown", to: "html"})
page.text
page.url
nano
parse-version-output
fn (stdout: Str?): Map
Parse pandoc version from pandoc --version stdout (first line: pandoc X.Y.Z).
Example
::pandoc/parse-version-output("pandoc 3.8\nFeatures: +server").version // "3.8"
::pandoc/parse-version-output(null) // {version: "", raw: ""}
start-convert
fn (input: Str, opts: ConvertOpts): Map
Start a pandoc document conversion in a container without waiting for completion.
Returns the box task info from ::box/start. Use ::task/await on the
returned id to wait for the result.
Example
info ::pandoc/start-convert("hot://uploads/notes.md", {from: "markdown", to: "html"})
result ::hot::task/await(info.id)
small
start-convert-text
fn (text: Str, opts: ConvertOpts): Map
Start an inline-text pandoc conversion in a container without waiting for completion.
Returns the box task info from ::box/start. Use ::task/await on the
returned id to wait for the result.
Example
info ::pandoc/start-convert-text("# Hi", {from: "markdown", to: "html"})
result ::hot::task/await(info.id)
nano
version
fn (): Map
fn (image: Str?): Map
Return pandoc version information from pandoc --version.
Example
ver ::pandoc/version()
ver.version
nano
Types
ConvertOpts
ConvertOpts type {
from: Str?,
to: Str,
standalone: Bool?,
template: Str?,
toc: Bool?,
extra-args: Vec<Str>?,
output: Str?,
image: Str?,
size: Str?,
timeout: Int?
}
Options for pandoc conversion.
Fields
from— Input format, e.g."markdown","html"(omit for auto-detect)to— Output format, e.g."html","pdf","docx"(required)standalone— Emit full standalone document (default:false)template— Custom template file path inside the containertoc— Include table of contents (default:falsewhen omitted)extra-args— Additional pandoc CLI arguments, one token per elementoutput— Outputhot://URL (default: auto-generated)image— Override Docker image (must havepandocin PATH)size— Box size override (convertdefault"small",convert-textdefault"nano")