Documentation
¶
Index ¶
- func ExtractText(n ast.Node, source []byte, buf *bytes.Buffer)
- func HeadingLine(heading *ast.Heading, f *lint.File) int
- func HeadingText(heading *ast.Heading, source []byte) string
- func IsTable(para *ast.Paragraph, f *lint.File) bool
- func ParagraphLine(para *ast.Paragraph, f *lint.File) int
- func SectionBody(paragraphs []SectionParagraph, start, end int) string
- func SectionEnd(headings []SectionHeading, i, totalLines int) int
- type SectionHeading
- type SectionParagraph
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractText ¶
ExtractText recursively writes the text content of n and its descendants into buf.
func HeadingLine ¶
HeadingLine returns the 1-based source line of a heading node. Setext headings expose their line via Lines(); ATX headings are found by walking inline descendants until the first text segment. Returns 1 as a safe fallback.
func HeadingText ¶
HeadingText returns the plain-text content of a heading by recursively extracting all text segments from its children.
func IsTable ¶
IsTable reports whether a paragraph node is actually a GFM table (goldmark parses tables as paragraphs when the table extension is absent). It checks whether the first line starts with "|".
func ParagraphLine ¶
ParagraphLine returns the 1-based source line of a paragraph node.
func SectionBody ¶ added in v0.16.0
func SectionBody(paragraphs []SectionParagraph, start, end int) string
SectionBody concatenates paragraph plain text for paragraphs whose start line falls in [start, end). Joins with a space so adjacent paragraphs do not appear glued together to a substring/regex matcher.
func SectionEnd ¶ added in v0.16.0
func SectionEnd(headings []SectionHeading, i, totalLines int) int
SectionEnd returns the exclusive end line of the section starting at headings[i]. The section ends at the first heading at the same or shallower level after headings[i], or at totalLines+1 when no such heading exists. Nested sub-sections stay inside.
Types ¶
type SectionHeading ¶ added in v0.16.0
SectionHeading is a heading discovered by CollectSectionHeadings, carrying the level and source line needed to compute a section's body range.
func CollectSectionHeadings ¶ added in v0.16.0
func CollectSectionHeadings(f *lint.File) []SectionHeading
CollectSectionHeadings returns every heading in the document ordered by source line. Used by content rules (MDS057, MDS058) that need to walk heading-bounded sections.
type SectionParagraph ¶ added in v0.16.0
SectionParagraph is a non-table paragraph discovered by CollectSectionParagraphs, carrying its 1-based source line and the plain text used for section-wide body matches.
func CollectSectionParagraphs ¶ added in v0.16.0
func CollectSectionParagraphs(f *lint.File) []SectionParagraph
CollectSectionParagraphs returns every non-table paragraph with its 1-based source line and plain text. Goldmark parses pipe-delimited tables as paragraphs when the table extension is absent; those are filtered so cell text does not pollute section bodies.