|
| tuple[list[tuple[str, str]], State] | options_to_items (str text, int line_offset=0, int column_offset=0) |
| |
| Iterable[tuple[KeyToken, ValueToken|None]] | _to_tokens (str text, State state, int line_offset=0, int column_offset=0) |
| |
| Iterable[Token] | _tokenize (str text, State state) |
| |
| None | _scan_to_next_token (StreamBuffer stream, State state) |
| |
|
KeyToken|ValueToken | _scan_plain_scalar (StreamBuffer stream, State state, bool is_key=False) |
| |
|
list[str] | _scan_plain_spaces (StreamBuffer stream, bool allow_newline=True) |
| |
|
str | _scan_line_break (StreamBuffer stream) |
| |
|
KeyToken|ValueToken | _scan_flow_scalar (StreamBuffer stream, Literal["'", '"'] style, bool is_key=False) |
| |
|
list[str] | _scan_flow_scalar_non_spaces (StreamBuffer stream, bool double, Position start_mark) |
| |
|
list[str] | _scan_flow_scalar_spaces (StreamBuffer stream, Position start_mark) |
| |
|
list[str] | _scan_flow_scalar_breaks (StreamBuffer stream) |
| |
|
ValueToken | _scan_block_scalar (StreamBuffer stream, Literal["|", ">"] style, State state) |
| |
|
tuple[bool|None, int|None] | _scan_block_scalar_indicators (StreamBuffer stream, Position start_mark) |
| |
|
None | _scan_block_scalar_ignored_line (StreamBuffer stream, Position start_mark, State state) |
| |
|
tuple[list[str], int, Position] | _scan_block_scalar_indentation (StreamBuffer stream) |
| |
|
tuple[list[str], Position] | _scan_block_scalar_breaks (StreamBuffer stream, int indent) |
| |
Parser for directive options.
This is a highly restricted parser for YAML,
which only allows a subset of YAML to be used for directive options:
- Only block mappings are allowed at the top level
- Mapping keys are parsed as strings (plain or quoted)
- Mapping values are parsed as strings (plain, quoted, literal `|`, folded `>`)
- `#` Comments are allowed and blank lines
Adapted from:
https://github.com/yaml/pyyaml/commit/957ae4d495cf8fcb5475c6c2f1bce801096b68a5
For a good description of multi-line YAML strings, see:
https://stackoverflow.com/a/21699210/5033292