GitHub Markdown export
Export md source or semantic Document trees as GitHub-flavored Markdown (GFM).
Both md2gfm and mdhtml2gfm resolve cross-references, numbering, captions, and citations through the shared Rust index without mutating their input, retaining complete YAML frontmatter.
gfm = md2gfm("# Intro\n\nSee [@sec-a].\n\n## Details {#sec-a}\n\nDone.")
assert "Details" in gfm and not gfm.warnings
Invalid reference targets, heading-numbering schemes, or cite_style values raise ValueError.
md2gfm
def md2gfm(
src:str, # Source text in the `md` dialect
dest:str | Path | None=None, # Optional output file path
reftypes:dict | None=None, # Override reference-type prefixes
number_headings:str | dict | bool | None=None, # Heading numbering scheme, `False`, or `None`
math:"Literal['brackets', 'dollars', 'off']"='brackets', # Math syntax mode
implicit_figures:bool=False, # Promote image-only paragraphs to figures?
templates=None, # Optional `TemplateDelimiter` sequence
tmpl=None, # Optional `(node) -> str | None` renderer for semantic operations
raw:tuple[str, ...]=('md', 'gfm'), # Raw block/inline formats to pass through verbatim
imgdir:str | Path | None=None, # Optional directory to extract `data:` URI images into
link=None, # Optional `(url) -> str | None` URL rewriter
cite_style:"Literal['author-year', 'numeric'] | None"=None, # Citation style (`None` inherits metadata)
)->Md: # Exported GFM (`str` subclass) carrying `.warnings`
Convert md source directly to GitHub-flavored Markdown through the shared Document representation.
mdhtml2gfm
def mdhtml2gfm(
src, # `Document`, symbolic MDHTML string, or `fast5ever` DOM
dest:str | Path | None=None, # Optional output file path
reftypes:dict | None=None, # Override reference-type prefixes
number_headings:str | dict | bool | None=None, # Heading numbering scheme, `False`, or `None`
tmpl=None, # Optional `(node) -> str | None` renderer for semantic operations
raw:tuple[str, ...]=('md', 'gfm'), # Raw block/inline formats to pass through verbatim; others are omitted
imgdir:str | Path | None=None, # Optional directory to extract `data:` URI images into
link=None, # Optional `(url) -> str | None` URL rewriter for non-extracted URLs
cite_style:"Literal['author-year', 'numeric'] | None"=None, # Citation style (`None` inherits metadata, defaulting to `'author-year'`)
)->Md: # Exported GFM (`str` subclass) carrying `.warnings`
Export a Document or symbolic MDHTML as GitHub-flavored Markdown with shared Rust numbering, citations, and reference text.
Md
def Md(
s:str, warnings:list
):
Exported Markdown (str subclass) carrying the export's .warnings list.