Documentation
¶
Overview ¶
Package blockutil provides shared helpers for container-style block directive parsers. Directives that open with a ":::name" fence and close with ":::" or ":::/name" share one Continue implementation, so every container nests, closes and recovers the same way.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContinueContainer ¶ added in v1.5.0
func ContinueContainer(pc parser.Context, node ast.Node, reader text.Reader, name string) parser.State
ContinueContainer is the Continue body shared by every ":::name" container. name is the node's canonical lowercased opener name ("tabs", "file-tree", an aside's type, a generic directive's name); closer aliases and case folding come from fence.Closes.
Rules, for the trimmed line:
- inside a fenced code block: content
- ":::word": a nested opener, pushed on the stack
- ":::": pops one nested opener; with none left, closes this block when no inner ':'-triggered block is still open
- ":::/x" that closes a nested opener: pops through it, taking any opener left open above it
- ":::/x" that closes this block: closes it, and Goldmark closes any child left open
- any other ":::/x": content
func HasInnerOpenBlocks ¶
HasInnerOpenBlocks reports whether a ':'-triggered container opened after node is still open, meaning a bare closing fence belongs to that inner container rather than to node.
Types ¶
type MarkerSegment ¶ added in v1.1.0
MarkerSegment is one chunk of a paragraph split at boundary-marker lines. A marker segment carries the regex capture in Marker; a leading segment (body lines that appeared before the first marker) has IsMarker false and an empty Marker. Body holds the lines that followed, or nil when the marker was immediately followed by another marker or ended the paragraph.
func SplitParagraphAtMarkers ¶ added in v1.1.0
func SplitParagraphAtMarkers(para *ast.Paragraph, source []byte, boundary *regexp.Regexp) []MarkerSegment
SplitParagraphAtMarkers splits para at every line matching boundary, returning the resulting sequence of marker and body chunks. It returns nil when no line matches, so callers can keep using the original node.
Call this only from a block parser's Close: goldmark runs every block parser's Close during the block phase, before the separate inline pass consumes Paragraph.Lines(). Because of that ordering the line segments are still authoritative here, and the body paragraphs built below go through inline parsing normally, so markup inside them renders as HTML rather than literal text.