parser

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractPreTOC

func ExtractPreTOC(doc *document.Document, headings []string)

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

func ExtractSections(doc *document.Document)

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

func GenerateFigureTable(doc *document.Document, heading string)

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

func InlineFootnotes(doc *document.Document)

InlineFootnotes converts end-of-document footnotes into inline spans placed immediately after their reference markers, then removes the footnote section.

func MarkNoNumber

func MarkNoNumber(doc *document.Document, exclude []string)

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

func MarkShortCodeBlocks(doc *document.Document, maxLines int)

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

func NumberReferences(doc *document.Document, biblioHeading, sitoHeading string)

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

func Parse(data []byte, code config.CodeConfig) (*document.Document, error)

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

func ParseFile(path string, code config.CodeConfig) (*document.Document, error)

ParseFile reads a Markdown file at path and returns the parsed Document. code configures syntax highlighting of fenced code blocks.

func ProcessFigures

func ProcessFigures(doc *document.Document)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL