Directive Parsing

Fenced code blocks are parsed as directives, if the block starts with {directive_name}, followed by arguments on the same line.

Directive options are read from a YAML block, if the first content line starts with ---, e.g.

```{directive_name} arguments
---
option1: name
option2: |
    Longer text block
---
content...
```

Or the option block will be parsed if the first content line starts with :, as a YAML block consisting of every line that starts with a :, e.g.

```{directive_name} arguments
:option1: name
:option2: other

content...
```

If the first line of a directive’s content is blank, this will be stripped from the content. This is to allow for separation between the option block and content.

exception myst_parser.parse_directives.DirectiveParsingError[source]

Raise on parsing/validation error.

myst_parser.parse_directives.parse_directive_text(directive_class: Type[docutils.parsers.rst.Directive], argument_str: str, content: str, validate_options: bool = True)[source]

Parse (and validate) the full directive text.

myst_parser.parse_directives.parse_directive_options(content: str, directive_class: Type[docutils.parsers.rst.Directive], validate: bool = True)[source]

Parse (and validate) the directive option section.

myst_parser.parse_directives.parse_directive_arguments(directive, arg_text)[source]

Parse (and validate) the directive argument section.