Documentation
¶
Overview ¶
Package document turns a file's bytes into a Document: raw content, fence-aware source lines, and a parsed frontmatter/data map. It is the format-agnostic substrate every rule reads from.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SplitTableCells ¶ added in v0.2.0
SplitTableCells splits one table row into trimmed cell values. It strips a single leading and trailing pipe if present and splits on unescaped pipes, preserving `\|` escapes inside cell text.
Types ¶
type Document ¶
type Document struct {
Path string
Format Format
Raw []byte
Lines []Line
Frontmatter map[string]any // markdown: parsed frontmatter; data: whole file
Body []byte // markdown content after frontmatter (nil for data)
BodyOffset int // byte offset in Raw where Body begins (0 for data)
}
Document is the parsed view of a single file.
type Format ¶
type Format string
Format identifies how a file is parsed and which rules apply to it.
type Line ¶
type Line struct {
Num int // 1-based line number
Text string // line content without the trailing newline
Start int // byte offset of the line start in Document.Raw
End int // byte offset just past Text (before the newline)
InFence bool // true when the line is INSIDE a fenced code block
}
Line is one source line with byte offsets and fenced-code-block state.
func SplitLines ¶
SplitLines splits raw into fence-aware Lines. A fence delimiter line toggles the in-fence state but is itself reported with InFence=false; only the lines strictly between an opening and closing delimiter are InFence=true.
type Table ¶ added in v0.2.0
type Table struct {
Cols int // column count, taken from the header row
HeaderIdx int // Lines index of the header row
SepIdx int // Lines index of the delimiter (separator) row
RowIdxs []int // Lines indices of the data rows
Align []string // per-column alignment: "", "left", "center", "right"
}
Table describes one GFM pipe table located in a Document. All index fields (HeaderIdx, SepIdx, RowIdxs) are positions into Document.Lines, not line numbers, so callers can read the underlying Line for offsets and text.