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: Iterable[str] = 'field(...)'#
url_schemes: Dict[str, Optional[myst_parser.config.main.UrlSchemeType]] = 'field(...)'#
ref_domains: Optional[Iterable[str]] = 'field(...)'#
fence_as_directive: Set[str] = 'field(...)'#
number_code_blocks: Sequence[str] = 'field(...)'#
title_to_header: bool = 'field(...)'#
heading_anchors: int = 'field(...)'#
heading_slug_func: Optional[Callable[[str], str]] = 'field(...)'#
html_meta: Dict[str, str] = '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: Sequence[str] = 'field(...)'#
highlight_code_blocks: bool = 'field(...)'#
inventories: Dict[str, Tuple[str, Optional[str]]] = '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() 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: 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: Union[str, Iterator[str]]) Optional[Dict[str, Any]][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