Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func NewDecoder() *Decoder
func (*Decoder) Decode ¶
Decode parses a block of text and builds a model.Document.
A model.Document can hold any sequence of alternating model.Text and model.Table objects.
Tables (rulers and data rows) are built from consecutive table-like lines of text. If a line cannot be parsed as a row or a ruler, the table is 'closed' and a new table will be created if necessary.
Any text which cannot be parsed is retained verbatim.
Thus it is always possible to parse a document (out of memory issues aside)
func (*Decoder) SetPrefixPattern ¶
SetPrefixPattern specifies which pattern should be used for detecting tables within e.g. code comments
type Encoder ¶
Encoder encodes a document as a byte slice, for printing
Invariants:
- optional prefix for all tables
- >= 0 items
- each item
- 0 or 1 unformated block of text
- 0 or 1 table
func (*Encoder) SetPrefix ¶
SetPrefix sets an explicit prefix to use on all tables
This is NOT typically desirable behaviour!
Typically, each table should retain the prefix of its first row (data or ruler)
To override this behaviour, specify a prefix which begins or ends with one or more whitespace characters.
-p xyz only used to match existing prefixes while decoding (ignore for encoder) -p " xyz " (prefix with leading or trailing spaces) explicitly set prefix for encoding
TODO: 2025-03-08 this is dodgy behaviour (side-effect based) and should either be removed or replaced by a more explicit operation