myst_parser.mdit_to_docutils.transforms#

Directives that can be applied to both Sphinx and docutils.

1.  Module Contents#

1.1.  Classes#

UnreferencedFootnotesDetector

Detect unreferenced footnotes and emit warnings.

SortFootnotes

Sort auto-numbered, labelled footnotes by the order they are referenced.

CollectFootnotes

Transform to move footnotes to the end of the document, and sort by label.

AddSlugIds

Emit each heading’s anchor slug as an additional (secondary) id.

PrioritiseExplicitIds

Reorder section["ids"] so an explicitly named target’s id is first.

ResolveAnchorIds

Transform for resolving [name](#id) type links.

1.2.  API#

class myst_parser.mdit_to_docutils.transforms.UnreferencedFootnotesDetector(document, startnode=None)[source]#

Bases: docutils.transforms.Transform

Detect unreferenced footnotes and emit warnings.

Replicates sphinx-doc/sphinx#12730, but also allows for use in docutils (without sphinx).

Initialization

Initial setup for in-place document transforms.

default_priority = None#
apply(**kwargs: Any) None[source]#

Apply the transform.

class myst_parser.mdit_to_docutils.transforms.SortFootnotes(document, startnode=None)[source]#

Bases: docutils.transforms.Transform

Sort auto-numbered, labelled footnotes by the order they are referenced.

This is run before the docutils Footnote transform, where numbered labels are assigned.

Initialization

Initial setup for in-place document transforms.

default_priority = None#
apply(**kwargs: Any) None[source]#

Apply the transform.

class myst_parser.mdit_to_docutils.transforms.CollectFootnotes(document, startnode=None)[source]#

Bases: docutils.transforms.Transform

Transform to move footnotes to the end of the document, and sort by label.

Initialization

Initial setup for in-place document transforms.

default_priority = None#
apply(**kwargs: Any) None[source]#

Apply the transform.

class myst_parser.mdit_to_docutils.transforms.AddSlugIds(document, startnode=None)[source]#

Bases: docutils.transforms.Transform

Emit each heading’s anchor slug as an additional (secondary) id.

This makes the anchor actually exist in published HTML output.

It must run only after all other id assignment — docutils’ PropagateTargets (260) and sphinx’s SortIds (261) included — so that a slug can neither claim an id another element would otherwise receive, nor become a section’s primary id: primary ids (used by tocs, permalinks and objects.inv) are unchanged by this transform. Slugs are registered in document.ids directly (not via set_id), deliberately bypassing id_prefix: the raw slug is the anchor.

Initialization

Initial setup for in-place document transforms.

default_priority = 700#
apply(**kwargs: Any) None[source]#

Apply the transform.

class myst_parser.mdit_to_docutils.transforms.PrioritiseExplicitIds(document, startnode=None)[source]#

Bases: docutils.transforms.Transform

Reorder section["ids"] so an explicitly named target’s id is first.

Docutils’ PropagateTargets (priority 260) appends propagated target ids after the section’s implicit id, so themes, tocs, permalinks and objects.inv pick up the (unstable) implicit id. This moves the explicitly named id earliest in the id list (for multiple (name)= targets, that is the one nearest the heading) to the front; the implicit id remains in the list, as a secondary anchor, so previously published fragments keep working.

Initialization

Initial setup for in-place document transforms.

default_priority = 262#
apply(**kwargs: Any) None[source]#

Apply the transform.

class myst_parser.mdit_to_docutils.transforms.ResolveAnchorIds(document, startnode=None)[source]#

Bases: docutils.transforms.Transform

Transform for resolving [name](#id) type links.

Initialization

Initial setup for in-place document transforms.

default_priority = 879#
apply(**kwargs: Any) None[source]#

Apply the transform.