parseutils

package module
v0.0.0-...-681897b Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 14 Imported by: 2

Documentation

Overview

package parseutils is awesome, and does not use any logging.

Index

Constants

This section is empty.

Variables

View Source
var MNdTypes = []string{"nil", "Blk", "Inl", "Doc"}
View Source
var NodeTypeString = []string{
	"Error", "CData", "Docmt", "Elmnt", "Comnt", "Doctype",
}
View Source
var TheReader text.Reader
View Source
var TheSourceAfr []byte
View Source
var TheSourceBfr []byte

var theSRC []byte // string var NdKdNms []string

Functions

func DataOfHtmlNode

func DataOfHtmlNode(n *html.Node) string

DataOfHtmlNode returns a string that should be the value of both [Node.Data] and [Node.DataAtom] . If they differ, a warning is issued. Note that if the tag is not recognized, DataAtom is left empty.

TODO: Use strings.Clone ? .

func DoParseTree_html

func DoParseTree_html(s string) (*html.Node, error)

DoParseTree_html returns the parse tree for the HTML from the given string. The input is assumed to be UTF-8 encoded.

func DoParseTree_mkdn

func DoParseTree_mkdn(s string) (ast.Node, text.Reader, error)

DoParseTree_mkdn takes a string and returns the tree produced by the parser.

func FlattenParseTree_html

func FlattenParseTree_html(pHN *html.Node) ([]*html.Node, []int, []*CT.FilePosition, error)

func FlattenParseTree_mkdn

func FlattenParseTree_mkdn(pMN ast.Node) ([]ast.Node, []int, []*CT.FilePosition, error)

func HtmlWalk

func HtmlWalk(n *html.Node, walker wf_aWalker_html)

HtmlWalk walks a AST tree by the depth first search algorithm.

func NTstring

func NTstring(nt html.NodeType) string

Types

type KVpair

type KVpair struct{ Key, Value string }

func KVpairsFromAttributes_html

func KVpairsFromAttributes_html(atts []html.Attribute) []KVpair

func KVpairsFromAttributes_mkdn

func KVpairsFromAttributes_mkdn(atts []ast.Attribute) []KVpair

func (KVpair) String

func (kvp KVpair) String() string

type ParserResults_html

type ParserResults_html struct {
	RootNode  *html.Node
	NodeSlice []*html.Node
	XU.CommonCPR
}

func GenerateParserResults_html

func GenerateParserResults_html(s string) (*ParserResults_html, error)

func (*ParserResults_html) GetAllByAnyTag

func (pCPR *ParserResults_html) GetAllByAnyTag(ss []string) []*html.Node

func (*ParserResults_html) GetAllByTag

func (pCPR *ParserResults_html) GetAllByTag(s string) []*html.Node

GetAllByTag returns a slice of `*html.Node`. It checks the basic tag only, not any namespace. Note that these tag lookup func's default to searching the `ListNodesP`, not the tree of `Node`s.

func (*ParserResults_html) NodeCount

func (p *ParserResults_html) NodeCount() int

func (*ParserResults_html) NodeDebug

func (p *ParserResults_html) NodeDebug(i int) string

func (*ParserResults_html) NodeEcho

func (p *ParserResults_html) NodeEcho(i int) string

func (*ParserResults_html) NodeInfo

func (p *ParserResults_html) NodeInfo(i int) string

type ParserResults_mkdn

type ParserResults_mkdn struct {
	RootNode  ast.Node
	NodeSlice []ast.Node
	Reader    text.Reader
	XU.CommonCPR
}

ParserResults_mkdn is a bit dodgy cos `ast.Node` is an interface, not a struct.

func GenerateParserResults_mkdn

func GenerateParserResults_mkdn(s string) (*ParserResults_mkdn, error)

func (*ParserResults_mkdn) GetAllByTag

func (pCPR *ParserResults_mkdn) GetAllByTag(s string) []ast.Node

GetAllByTag returns a slice of `ast.Node`. It checks the basic tag only, not any namespace. Note that these tag lookup func's default to searching the `ListNodesP`, not the tree of `Node`s.

func (*ParserResults_mkdn) NodeCount

func (p *ParserResults_mkdn) NodeCount() int

func (*ParserResults_mkdn) NodeDebug

func (p *ParserResults_mkdn) NodeDebug(i int) string

func (*ParserResults_mkdn) NodeEcho

func (p *ParserResults_mkdn) NodeEcho(i int) string

func (*ParserResults_mkdn) NodeInfo

func (p *ParserResults_mkdn) NodeInfo(i int) string

Jump to

Keyboard shortcuts

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