Documentation
¶
Index ¶
- func ExtractPreTOC(doc *document.Document, headings []string)
- func ExtractSections(doc *document.Document)
- func GenerateFigureTable(doc *document.Document, heading string)
- func InlineFootnotes(doc *document.Document)
- func MarkNoNumber(doc *document.Document, exclude []string)
- func MarkShortCodeBlocks(doc *document.Document, maxLines int)
- func NumberReferences(doc *document.Document, biblioHeading, sitoHeading string)
- func Parse(data []byte, code config.CodeConfig) (*document.Document, error)
- func ParseFile(path string, code config.CodeConfig) (*document.Document, error)
- func ProcessFigures(doc *document.Document)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractPreTOC ¶
ExtractPreTOC removes the named h2 sections from doc.Body and places them in doc.PreTOC so they can be rendered before the table of contents.
func ExtractSections ¶
ExtractSections splits doc.Body by h2 headings and populates doc.Sections. Each section contains the rendered HTML between two consecutive h2s, and a parsed Table if a Markdown table is present.
func GenerateFigureTable ¶
GenerateFigureTable inserts a <nav class="doc-tof"> block inside the named h2 section, linking each entry to its figure by ID. No-op if heading is empty or doc.Figures is empty.
func InlineFootnotes ¶
InlineFootnotes converts end-of-document footnotes into inline spans placed immediately after their reference markers, then removes the footnote section.
func MarkNoNumber ¶
MarkNoNumber adds class="no-number" to headings whose text appears in exclude and sets NoNumber on the corresponding TOC entries, suppressing CSS counters.
func MarkShortCodeBlocks ¶ added in v0.0.7
MarkShortCodeBlocks adds class="code-keep" to <pre> blocks of at most maxLines lines, letting CSS keep only those from being split across pages. Longer blocks stay breakable on purpose: a block taller than the page area cannot be kept whole, and forcing it risks paged.js pushing it off the page entirely. No-op when maxLines is zero or negative.
func NumberReferences ¶
NumberReferences numbers the list items in the bibliography and sitography sections of doc.Body. The sitography counter continues from where the bibliography left off.
func Parse ¶
Parse converts Markdown bytes to a Document, extracting front matter metadata, building a TOC from headings, and splitting the body into h2-delimited sections. code configures syntax highlighting of fenced code blocks.
func ParseFile ¶
ParseFile reads a Markdown file at path and returns the parsed Document. code configures syntax highlighting of fenced code blocks.
func ProcessFigures ¶
ProcessFigures assigns sequential IDs (fig-1, fig-2, …) to <figure> elements that contain a <figcaption>, and populates doc.Figures with ID/caption pairs.
Types ¶
This section is empty.