Skip to content

syntax/unified/mdast

The Obsidian syntax as an mdast-util-from-markdown extension: the tokens of micromark.ts as mdast nodes.

Where mdast already has a node for a construct, the extension gives that node: footnoteReference and footnoteDefinition as in GFM, yaml as in mdast-util-frontmatter, and inlineMath and math as in mdast-util-math. Every other construct gets a node of its own, and a task marker becomes fields of its list item. MDAST_NODE_TYPES maps each node of ObsidianNode to its mdast node or field.

Interface Description
BlockId A block id, ^id at the end of a block.
Callout A callout: a quote that opens with [!type].
Embed An embed, ![[target]].
Highlight A highlight, ==text==.
InlineFootnote An inline footnote, ^[text].
InlineMath Inline math, $tex$ or $$tex$$ inside a paragraph, as mdast-util-math names it.
InternalLink An internal link, [[target]].
InternalLinkFields The parts of an internal link or an embed.
MathBlock A math block, $$ lines, as mdast-util-math names it.
ObsidianComment An inline comment, %%text%%.
ObsidianCommentBlock A comment block, %% lines.
Tag A tag, #name.
Function Description
parseMdast Parses a markdown document into an mdast tree with the Obsidian syntax, or with the syntax and the quirks the options ask for. With the looseList: 'blank-line-anywhere' quirk, a list item is spread when a blank line inside it is followed by more of it, as in Obsidian’s tree, so a list renders loose when any of its items is.
Type Description
ParseMdastOptions The options of parseMdast: the syntax to read, and the quirks to apply.
Variable Description
MDAST_NODE_TYPES Where each node of the Obsidian syntax goes in mdast: a node type, or a field of a node.
mdastObsidianMarkdown The Obsidian syntax with the GFM extensions Obsidian supports: tables, strikethrough and bare URLs.
mdastObsidianSyntax The Obsidian syntax as an mdast-util-from-markdown extension, for the tokens of micromarkObsidianSyntax.