5 Module Reference
5.1 Core
(require punct/core) | package: punct-lib |
parameter
(current-metas) → (or/c hash-eq? #f)
(current-metas metas) → void? metas : (or/c hash-eq? #f)
The only key automatically defined in every metadata table is 'here-path, which holds the absolute path to the source file.
If no Punct file is currently being compiled, this parameter will hold #f by default. In particular, this parameter is not automatically set to a Punct file’s metas during the rendering phase (e.g., doc->html).
procedure
key : symbol? val : (not/c procedure?)
syntax
(? key val-expr ...)
#lang punct •?[title "Example Title" author "Me"] ...
5.2 Doc
(require punct/doc) | package: punct-lib |
The bindings provided by this module are also provided by punct/core.
struct
(struct document (metas body footnotes) #:extra-constructor-name make-document #:prefab) metas : hash-eq? body : (listof xexpr?) footnotes : (listof xexpr?)
Changed in version 1.0 of package punct-lib: body and footnotes now guaranteed to be valid X-expressions and not simply lists.
5.3 Fetch
(require punct/fetch) | package: punct-lib |
procedure
src : path-string?
procedure
(get-doc-ref src key) → any/c
src : path-string? key : symbol?
5.4 Parse
(require punct/parse) | package: punct-lib |
procedure
(parse-markup-elements metas elements #:extract-inline? extract? #:parse-footnotes? parse-fn?) → (or/c document? list?) metas : hash-eq? elements : list? extract? : #t parse-fn? : #f
If #:extract-inline? is #true, and if the parsed document contains only a single paragraph element at the root level, then the inline content of the paragraph is returned as a list. Otherwise, the entire result is returned as a document.
The #:parse-footnotes? argument determines whether the commonmark parser will parse Markdown-style footnote references and definitions in elements.
> (define elems '("# Title\n\nA paragraph with *italic* text, and " 1 (custom "custom element"))) > (parse-markup-elements (hasheq) elems)
'#s(document
#hasheq()
((heading ((level "1")) "Title")
(paragraph
"A paragraph with "
(italic "italic")
" text, and 1"
(custom "custom element")))
())