myst_parser.config.main#

The configuration for the myst parser.

1.  Module Contents#

1.1.  Classes#

UrlSchemeType

Type of the external schemes dictionary.

MdParserConfig

Configuration options for the Markdown Parser.

1.2.  Functions#

check_extensions

Check that the extensions are a list of known strings

check_url_schemes

Check that the external schemes are of the right format.

check_sub_delimiters

Check that the sub_delimiters are a tuple of length 2 of strings of length 1

check_inventories

Check that the inventories are a dict of {str: (str, Optional[str])}

check_heading_slug_func

Check that the heading_slug_func is a callable.

check_fence_as_directive

Check that the extensions are a sequence of known strings

merge_file_level

Merge the file-level topmatter with the global config.

read_topmatter

Read the (optional) YAML topmatter from a source string.

1.3.  API#

myst_parser.config.main.check_extensions(inst: MdParserConfig, field: dataclasses.Field, value: Any) None[source]#

Check that the extensions are a list of known strings

class myst_parser.config.main.UrlSchemeType[source]#

Bases: typing.TypedDict

Type of the external schemes dictionary.

Initialization

Initialize self. See help(type(self)) for accurate signature.

url: str = None#
title: str = None#
classes: list[str] = None#
myst_parser.config.main.check_url_schemes(inst: MdParserConfig, field: dataclasses.Field, value: Any) None[source]#

Check that the external schemes are of the right format.

myst_parser.config.main.check_sub_delimiters(_: MdParserConfig, field: dataclasses.Field, value: Any) None[source]#

Check that the sub_delimiters are a tuple of length 2 of strings of length 1

myst_parser.config.main.check_inventories(_: MdParserConfig, field: dataclasses.Field, value: Any) None[source]#

Check that the inventories are a dict of {str: (str, Optional[str])}

myst_parser.config.main.check_heading_slug_func(inst: MdParserConfig, field: dataclasses.Field, value: Any) None[source]#

Check that the heading_slug_func is a callable.

myst_parser.config.main.check_fence_as_directive(inst: MdParserConfig, field: dataclasses.Field, value: Any) None[source]#

Check that the extensions are a sequence of known strings

class myst_parser.config.main.MdParserConfig[source]#

Configuration options for the Markdown Parser.

Note in the sphinx configuration these option names are prepended with myst_

commonmark_only: bool = 'field(...)'#
gfm_only: bool = 'field(...)'#
enable_extensions: set[str] = 'field(...)'#
disable_syntax: collections.abc.Iterable[str] = 'field(...)'#
url_schemes: dict[str, myst_parser.config.main.UrlSchemeType | None] = 'field(...)'#
ref_domains: collections.abc.Iterable[str] | None = 'field(...)'#
fence_as_directive: set[str] = 'field(...)'#
number_code_blocks: collections.abc.Sequence[str] = 'field(...)'#
title_to_header: bool = 'field(...)'#
heading_anchors: int = 'field(...)'#
heading_slug_func: collections.abc.Callable[[str], str] | None = 'field(...)'#
html_meta: dict[str, str] = 'field(...)'#
footnote_sort: bool = 'field(...)'#
footnote_transition: bool = 'field(...)'#
words_per_minute: int = 'field(...)'#
substitutions: dict[str, Any] = 'field(...)'#
sub_delimiters: tuple[str, str] = 'field(...)'#
dmath_allow_labels: bool = 'field(...)'#
dmath_allow_space: bool = 'field(...)'#
dmath_allow_digits: bool = 'field(...)'#
dmath_double_inline: bool = 'field(...)'#
update_mathjax: bool = 'field(...)'#
mathjax_classes: str = 'field(...)'#
enable_checkboxes: bool = 'field(...)'#
suppress_warnings: collections.abc.Sequence[str] = 'field(...)'#
highlight_code_blocks: bool = 'field(...)'#
inventories: dict[str, tuple[str, str | None]] = 'field(...)'#
copy(**kwargs: Any) myst_parser.config.main.MdParserConfig[source]#

Return a new object replacing specified fields with new values.

Note: initiating the copy will also validate the new fields.

classmethod get_fields() tuple[dataclasses.Field, ...][source]#

Return all attribute fields in this class.

as_dict(dict_factory=dict) dict[source]#

Return a dictionary of field name -> value.

as_triple() collections.abc.Iterable[tuple[str, Any, dataclasses.Field]][source]#

Yield triples of (name, value, field).

myst_parser.config.main.merge_file_level(config: myst_parser.config.main.MdParserConfig, topmatter: dict[str, Any], warning: collections.abc.Callable[[myst_parser.warnings_.MystWarnings, str], None]) myst_parser.config.main.MdParserConfig[source]#

Merge the file-level topmatter with the global config.

Parameters:
  • config – Global config.

  • topmatter – Topmatter from the file.

  • warning – Function to call with a warning (type, message).

Returns:

A new config object

exception myst_parser.config.main.TopmatterReadError[source]#

Bases: Exception

Topmatter parsing error.

Initialization

Initialize self. See help(type(self)) for accurate signature.

myst_parser.config.main.read_topmatter(text: str | collections.abc.Iterator[str]) dict[str, Any] | None[source]#

Read the (optional) YAML topmatter from a source string.

This is identified by the first line starting with , then read up to a terminating line of , or .

Parameters:

source – The source string to read from

Returns:

The topmatter