Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeOnPlaceWithUnderscore(line []byte) []byte
- func HasPrefix(line []byte, pre string) bool
- func ReadQuotedWords(workingTagSpec []byte) (word []byte, rest []byte)
- func ReadTagName(tagSpec []byte) (tagName []byte, rest []byte)
- func ReadWord(line []byte) (word []byte, rest []byte)
- func ReparentChildren(dst, src *Node)
- func SkipWhiteSpace(line []byte) []byte
- func TrimLeft(line []byte, s byte) (int, []byte)
- type AttrType
- type Attribute
- type ByteRenderer
- type Node
- func (n *Node) AddClass(newClass []byte)
- func (n *Node) AddClassString(newClass string)
- func (n *Node) AppendChild(c *Node)
- func (n *Node) Clone() *Node
- func (n *Node) InsertBefore(newChild, oldChild *Node)
- func (n *Node) RemoveChild(c *Node)
- func (n *Node) RenderDiagramNode(br *ByteRenderer) error
- func (n *Node) RenderExampleNode(br *ByteRenderer) error
- func (n *Node) RenderHTML(br *ByteRenderer) error
- func (n *Node) RenderNormalNode(br *ByteRenderer) error
- func (n Node) String() string
- type NodeType
- type Parser
- func (p *Parser) NewNode(parent *Node, text *Text) *Node
- func (p *Parser) Parse() error
- func (p *Parser) ParseBlock(parent *Node)
- func (p *Parser) ParseIncludeFile(parent *Node, fileName string, processYAML bool) (*Parser, error)
- func (p *Parser) ParseVerbatim(parent *Node) error
- func (p *Parser) ParseVerbatimIncluded(parent *Node) error
- func (p *Parser) PeekParagraphFirstLine() *Text
- func (p *Parser) PreprocesLine(lineSt *Text) *Text
- func (p *Parser) ReadAnyParagraph(min_indentation int) *Text
- func (p *Parser) ReadLine() *Text
- func (p *Parser) ReadParagraph(indentation int) *Text
- func (p *Parser) RenderHTML() []byte
- func (p *Parser) SkipBlankLines() bool
- func (p *Parser) UnreadLine(line *Text)
- func (p *Parser) UnreadParagraph(para *Text)
- type Text
- type TreeNode
Constants ¶
const EndHTMLTag = '>'
const StartHTMLTag = '<'
Variables ¶
var ErrBufferExceeded = errors.New("max buffer exceeded")
ErrBufferExceeded means that the buffering limit was exceeded.
var HeadingElements = []string{"h1", "h2", "h3", "h4", "h5", "h6"}
var NoBlockElements = []string{
"p", "code", "b", "i", "hr", "em", "strong", "small", "s",
}
var VoidElements = []string{
"area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr",
}
Functions ¶
func ReadQuotedWords ¶
func ReadTagName ¶
func ReparentChildren ¶
func ReparentChildren(dst, src *Node)
ReparentChildren reparents all of src's child nodes to dst.
func SkipWhiteSpace ¶
Types ¶
type Attribute ¶
An Attribute is an attribute key-value pair. Key is alphabetic (and hence does not contain escapable characters like '&', '<' or '>'), and Val is unescaped (it looks like "a<b" rather than "a<b").
func ReadTagAttrKey ¶
type ByteRenderer ¶
func (*ByteRenderer) CloneBytes ¶
func (r *ByteRenderer) CloneBytes() []byte
CloneBytes returns a copy of the buffer contents, so the returned copy is owned by the caller
func (*ByteRenderer) Render ¶
func (r *ByteRenderer) Render(inputs ...any)
func (*ByteRenderer) Renderln ¶
func (r *ByteRenderer) Renderln(inputs ...any)
type Node ¶
type Node struct { TreeNode Type NodeType Level int Outline string RawText *Text InnerText []byte Indentation int LineNumber int Name string Id []byte Class []byte Src []byte Href []byte Bucket []byte Number []byte BulletText []byte Attr []Attribute RestLine []byte // contains filtered or unexported fields }
func (*Node) AddClassString ¶
func (*Node) AppendChild ¶
AppendChild adds a node c as a child of n.
It will panic if c already has a parent or siblings.
func (*Node) Clone ¶
Clone returns a new node with the same type, data and attributes. The Clone has no parent, no siblings and no children.
func (*Node) InsertBefore ¶
InsertBefore inserts newChild as a child of n, immediately before oldChild in the sequence of n's children. oldChild may be nil, in which case newChild is appended to the end of n's children.
It will panic if newChild already has a parent or siblings.
func (*Node) RemoveChild ¶
RemoveChild removes a node c that is a child of n. Afterwards, c will have no parent and no siblings.
It will panic if c's parent is not n.
func (*Node) RenderDiagramNode ¶
func (n *Node) RenderDiagramNode(br *ByteRenderer) error
func (*Node) RenderExampleNode ¶
func (n *Node) RenderExampleNode(br *ByteRenderer) error
func (*Node) RenderHTML ¶
func (n *Node) RenderHTML(br *ByteRenderer) error
RenderHTML renders recursively to HTML this node and its children (if any)
func (*Node) RenderNormalNode ¶
func (n *Node) RenderNormalNode(br *ByteRenderer) error
type Parser ¶
type Parser struct { Ids map[string]int // To provide numbering of different entity classes Figs map[string]int // To provide numbering of figs of different types in the document Xref map[string]*Node Config *yaml.YAML // contains filtered or unexported fields }
func NewParser ¶
NewParser parses a document reading lines from linescanner. filename is for logging/tracing purposes.
func ParseFromFile ¶
ParseFromFile reads a file and preprocesses it in memory
func (*Parser) NewNode ¶
NewNode creates a node from the text that is passed. The new node is set to the proper type and its attributes populated. If the line starts with a proper tag, it is processed and the node is updated accordingly.
func (*Parser) ParseBlock ¶
ParseBlock parses the segment of the document that belongs to the block represented by the node. The node will have as child nodes all elements that are at the same indentation
func (*Parser) ParseIncludeFile ¶
ParseIncludeFile reads an included file and preprocesses it in memory
func (*Parser) ParseVerbatim ¶
func (*Parser) ParseVerbatimIncluded ¶
func (*Parser) PeekParagraphFirstLine ¶
func (*Parser) PreprocesLine ¶
PreprocesLine applies some preprocessing to the raw line that was just read from the stream. Only preprocessing which is local to the current line can be applied.
func (*Parser) ReadAnyParagraph ¶
ReadAnyParagraph reads all contiguous lines with the same indentation, if their indentation equal or greater than min_indentation. It skips all blank lines at the beginning.
func (*Parser) ReadLine ¶
ReadLine returns one line from the underlying bufio.Scanner. It supports one-level backtracking, with the UnreadLine method.
func (*Parser) ReadParagraph ¶
ReadParagraph is like ReadLine but returns all contiguous lines at the same level of indentation. The paragraph starts at the first non-blank line with more indentation than the specified one. A line starting with a block tag is considered a different paragraph, and stops the current paragraph.
func (*Parser) RenderHTML ¶
func (*Parser) SkipBlankLines ¶
SkipBlankLines skips blank or comment lines until EOF. Returns true if a non-blank line was found, false on EOF.
func (*Parser) UnreadLine ¶
UnreadLine allows one-level backtracking by buffering one line that was already returned from bufio.Scanner
func (*Parser) UnreadParagraph ¶
UnreadParagraph allows one-level backtracking by buffering one paragraph that was already returned from bufio.Scanner