Documentation
¶
Overview ¶
Package fmlines is a front matter line extractor — not a parser: it tokenizes a header line by line and classifies each one; what the lines MEAN (the dialect: which keys, which sections) is the consumer's business. Every line read becomes a token, the unrecognized ones too — raw and numbered, never lost.
It reads through a github.com/pablo-botella/linereader LineReader. The family: ReadLine takes ONE line into the list and tells its type, ReadHeader takes a fenced header (.md) and stops right after the closing --- — the body stays in the reader, keep reading it there — and ReadAll takes everything (.fm: everything is header).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FmLine ¶
type FmLineReader ¶
type FmLineReader struct {
Lines *FmLines
Reader linereader.IoLineReader
}
func NewFmLineReader ¶
func NewFmLineReader(reader io.Reader, lines *FmLines) *FmLineReader
func (*FmLineReader) ReadAll ¶
func (flr *FmLineReader) ReadAll() error
func (*FmLineReader) ReadHeader ¶
func (flr *FmLineReader) ReadHeader() error
func (*FmLineReader) ReadLine ¶
func (flr *FmLineReader) ReadLine() (FmLineType, error)
type FmLineType ¶
type FmLineType int
const ( FmLineInvalid FmLineType = 0 FmLineStartBlock FmLineType = 0x0001 FmLineEndBlock FmLineType = 0x0002 FmLineKeyValue FmLineType = 0x0010 FmLineSection FmLineType = 0x0020 FmLineEmpty FmLineType = 0x0100 )
type FmLines ¶
type FmLines []*FmLine
func (*FmLines) ReadAll ¶
func (lines *FmLines) ReadAll(lr linereader.IoLineReader) error
ReadAll tokenizes a bare header (.fm) into the list: every line to EOF is front matter — no fences, no body.
func (*FmLines) ReadHeader ¶
func (lines *FmLines) ReadHeader(lr linereader.IoLineReader) error
ReadHeader tokenizes a fenced header (.md) into the list and STOPS right after the closing ---: the body stays in the reader — keep reading it there, by lines, by bytes, or hand the reader to any io.Reader consumer. The first line must be the opening fence; when it is not, there is no front matter: that single line comes back as the only token (read is read, nothing gets lost) and the rest of the document was never touched. An unclosed fence is an error.
func (*FmLines) ReadLine ¶
func (lines *FmLines) ReadLine(lr linereader.IoLineReader) (FmLineType, error)
ReadLine reads ONE line from the reader, puts it into the list and tells what it was. Fences are not its business (that is ReadHeader's): a --- here is just an invalid line. io.EOF when the reader is done.