blockutil

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package blockutil provides shared helpers for container-style block directive parsers. Directives that open with a ":::name" fence and close with ":::" track how many nested container fences are currently open so that a closing fence is matched to the correct block.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteDepth

func DeleteDepth(pc parser.Context, node ast.Node)

DeleteDepth removes the depth entry for node.

func GetDepth

func GetDepth(pc parser.Context, node ast.Node) int

GetDepth returns the nesting depth recorded for node, or 0 if none.

func HasInnerOpenBlocks

func HasInnerOpenBlocks(pc parser.Context, node ast.Node) bool

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.

func SetDepth

func SetDepth(pc parser.Context, node ast.Node, depth int)

SetDepth records the nesting depth for node.

Types

type MarkerSegment added in v1.1.0

type MarkerSegment struct {
	IsMarker bool
	Marker   string
	Body     *ast.Paragraph
}

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.

Jump to

Keyboard shortcuts

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