YAML keys
How the keys option selects values in yaml mode: exact matching, any depth, no paths or globs, and which lines the scan reads as keys.
keys names the mapping keys whose scalar values are prose. It is required in yaml mode, and it is the only thing that decides what is processed.
Matching #
A key matches when its source text, with trailing spaces removed, equals a member of keys code point for code point.
- Exact.
Descriptiondoes not matchdescription. There is no case folding, because case operations depend on the locale (Turkish dotless ı is the standing reason). - Any depth.
descriptionmatches wherever the key occurs, at any nesting level. There are no paths, no globs and no wildcards, so a machine-readdescriptionsomewhere else in the same file would be typeset too; list the keys only if you want every occurrence. - Keys are never processed. Only values.
- A quoted key never matches.
Input
Output
The first two keys match, at depth zero and inside meta. Title differs in case and the quoted key is declined.
Which lines are read as keys #
The scan goes line by line. A line yields a value to look at only when all of this holds:
- It is not blank, a comment (
#) or a directive (%), a document marker (---,...) or a line containing a tab. - After any block-sequence markers (
-, repeatable, as in- - key: v) it holds a key followed by:and a space or the end of the line. A colon not followed by a space is an ordinary character of the key, soa:b: vhas the keya:b. - The key text does not contain
",',{,[,&,*,!or#. This applies at every position, soa!b: valueyields nothing. - The key is in
keys. - The value begins on the same line. If it is empty, the more-indented lines that follow are a nested node and are scanned as lines of their own.
Lines that belong to a value (more indented than the key, or blank) are never scanned as keys. A multi-line value cannot leak mappings into the scan.
Input
Output
Choosing keys #
List only the keys you know hold prose. Listing every key is legal and is the scan's most exposed configuration: it converts a client name such as "HTPBE?" in French to "HTPBE ?" and puts a narrow no-break space into a string written for a search engine. Only you can tell those values from the prose ones, which is why the option is yours.
Related #
- YAML mode
- Quoting and scalar forms
- Frontmatter:
frontmatterKeysuses this matching
Normative text: spec/rules/modes.md (§3.8.2, §3.8.4).