Skip to content

syntax/options

Which syntax a parser reads, shared by every adapter: a preset, with any of its flags overridden.

Each flag turns on one construct. The GFM flags add the syntax of the GFM spec’s extensions, and the Obsidian flags add the Obsidian syntax. Every flag adds syntax that CommonMark reads as text or as something else, so a document that uses it parses differently, but none of them changes how a document without it parses. So the commonmark preset, with every flag off, passes the CommonMark spec suite, and gfm passes the GFM spec’s extension examples as well.

A quirk is different: it changes how valid CommonMark parses. Each quirk Obsidian has, measured against its reading view and its metadata worker (docs/spec-suites.md), is a flag of ObsidianQuirkFlags named after the behaviour. Every preset leaves every quirk at its CommonMark behaviour, so a quirk only applies when it is asked for.

Interface Description
ObsidianQuirkFlags The quirks: where Obsidian reads valid CommonMark differently. Each flag takes two values, the CommonMark behaviour (COMMONMARK_QUIRKS), which every preset keeps, and Obsidian’s (OBSIDIAN_QUIRKS).
ObsidianSyntaxFlags The constructs a parser can read, each turned on or off.
ObsidianSyntaxOptions The syntax a parser reads: a preset, obsidian by default, with any of its flags overridden, and any of the quirks.
Function Description
resolveObsidianQuirks Resolves options to the quirks they ask for: the CommonMark behaviour, with the overrides applied.
resolveObsidianSyntax Resolves options to the flags they turn on: the preset’s flags, with the overrides applied.
Type Description
ObsidianSyntaxPreset A named set of flags: commonmark has every flag off, gfm the GFM spec’s extensions, and obsidian everything Obsidian reads.
ResolveObsidianQuirksOptions The options of resolveObsidianQuirks.
ResolveObsidianSyntaxOptions The options of resolveObsidianSyntax.
Variable Description
COMMONMARK_QUIRKS The CommonMark behaviour of every quirk, which every preset keeps.
OBSIDIAN_QUIRK_FLAGS The names of the quirks, in a fixed order.
OBSIDIAN_QUIRKS Obsidian’s behaviour for every quirk, as its reading view and its metadata worker show it.
OBSIDIAN_SYNTAX_FLAGS The names of the flags, in a fixed order.
OBSIDIAN_SYNTAX_PRESETS The flags of each preset.