On this page:
4.1 Rendering HTML

4 Rendering

A Punct document is format-independent; when you want to use it in an output file, it must be rendered into that output file’s format.

Punct includes an HTML renderer, and is designed to include renderers for more formats in the future.

4.1 Rendering HTML

 (require punct/render/html) package: punct-lib


(doc->html doc [fallback])  string?

  doc : document?
  fallback : (-> symbol? list? list? xexpr?) = default-html-tag
Renders doc into a string containing HTML markup. Any custom elements are passed to fallback, which must return an X-expression.

For more information on using the fallback argument to render custom elements, see Rendering custom elements.


(default-html-tag tag attributes elements)  xexpr?

  tag : symbol?
  attributes : (listof (listof symbol? string?))
  elements : list?
Returns an X-expression comprised of tag, attributes and elements. Mainly used as the default fallback procedure for doc->html.

> (default-html-tag 'kbd '() '("Enter"))

'(kbd "Enter")

> (default-html-tag 'a '((href "http://example.com")) '("Link"))

'(a ((href "http://example.com")) "Link")