Documentation
¶
Overview ¶
Package mdcompose composes Markdown fragments into one coherent document. An embedded fragment — an entry body, a generated section — is demoted beneath the headings of the structure serving it, so no embedded heading outranks its container (d-cpt-5wv).
Headings are recognized in ATX form (`#` … `######`) outside fenced code blocks. Setext underlining is left untouched: graph entry bodies and served fragments are authored ATX throughout, and rewriting an underline would mean rewriting two lines on a guess about which one is prose.
Index ¶
Constants ¶
const MaxHeadingLevel = 6
MaxHeadingLevel is Markdown's deepest ATX heading. Demotion clamps here: a seventh `#` stops being a heading at all, so a fragment pushed past the floor collapses its deepest levels rather than degrading into paragraph text.
Variables ¶
This section is empty.
Functions ¶
func DemoteTo ¶
DemoteTo shifts every heading in fragment by one constant amount, so that its shallowest heading lands at level and the relative hierarchy is preserved. A fragment whose headings already sit at or below level is returned unchanged — the rule demotes into place, it never promotes a fragment toward the surface.
func SplitLeadingHeading ¶
SplitLeadingHeading splits a leading heading off fragment: when its first non-blank line is a heading, that heading's text is returned separately from the remaining body, so a composer can lift it into the container's own structure instead of nesting a title under a title. Otherwise title is empty and rest is fragment unchanged.
func TopHeadingLevel ¶
TopHeadingLevel reports the shallowest heading level in fragment, or 0 when it carries no heading. Callers composing their own structure use it to work out how deep an embedded fragment already sits.
Types ¶
This section is empty.