5.3 Fetch
| (require punct/fetch) | package: punct-lib |
procedure
src : path-string?
procedure
doc : document? key : symbol?
default : failure-result/c = (lambda () (raise (make-exn:fail ....)))
Changed in version 1.1 of package punct-lib: Removed get-doc-ref and replaced with get-meta
procedure
(read-source-metas src) → (or/c (and/c hash-eq? immutable?) #f)
src : path-string?
Returns #f if the first line of src is not a #lang punct line. Returns an empty hash table if src is a Punct source with no metadata block.
The result differs from the document-metas of the compiled document in these ways:
Metas set by code (with set-meta or ?) are not included, nor is here-path.
Quoted values are read with read-accept-reader, read-accept-lang and read-accept-compiled set to #f and with the default readtable, so a value that uses #reader or #lang is skipped.
If a key appears more than once in the block, the first value is used, as in the compiled document.
This function never raises an error because of a malformed metadata block, even where compiling src would fail. Instead:
A line with no :, or with nothing after the :, is skipped.
A line whose quoted value cannot be read with read (for example, an unclosed list) is skipped.
If the block has no closing line of hyphens, every line to the end of the file is treated as part of the block, so lines in the body that look like key: value will appear in the result.
If anything other than whitespace comes between the #lang line and the opening line of hyphens, there is no metadata block, and the result is an empty hash table.
Added in version 1.6 of package punct-lib.