std/htmltok
On this page
Index
- type
TokenType - type
Attribute - type
Token - type
Pend - type
Tokenizer- method
Tokenizer.next - method
Tokenizer.token - method
Tokenizer.raw - method
Tokenizer.err - method
Tokenizer.allow_cdata - method
Tokenizer.next_is_not_raw_text - method
Tokenizer.set_max_buf - method
Tokenizer.buffered
- method
- fn
tokenizer - fn
tokenizer_fragment
Types
TokenType
enum TokenType {
Error
Text
StartTag
EndTag
SelfClosingTag
Comment
Doctype
} derive EqGo’s TokenType.
Attribute
struct Attribute {
key: Str
val: Str
} derive EqGo’s Attribute without its namespace (the tokenizer never sets one): the key lower cased, the value unescaped.
Token
struct Token {
typ: TokenType
data: Str
attrs: List[Attribute]
} derive EqGo’s Token: data is the lower cased tag name of a tag, the unescaped text
of a text, comment or doctype; attrs are a tag’s attributes in order,
duplicates (by lower cased key) and empty keys dropped.
Pend
struct Pend {
k0: Int
k1: Int
v0: Int
v1: Int
}Go’s Tokenizer over a text held in memory. The key and value spans of the attribute being read (internal).
Tokenizer
struct Tokenizer {
src: Bytes
tt: TokenType
errc: Int
rs: Int
re: Int
max_buf: Int
ds: Int
de: Int
pend: Pend
attr: List[Int]
raw_tag: Str
text_raw: Bool
convert_nul: Bool
cdata: Bool
}Tokenizer.next
fn (var z: Tokenizer) next() -> TokenTypeGo’s Next: scans the next token and returns its type; Error at the end of
the input (see err) or when the buffer limit is exceeded.
Tokenizer.token
fn (var z: Tokenizer) token() -> TokenGo’s Token: the current token (it consumes the token’s data, as Go’s does:
call it once per next).
Tokenizer.raw
fn (z: Tokenizer) raw() -> StrGo’s Raw: the unmodified text of the current token; the raw texts of the tokens partition the input up to the Error token.
Tokenizer.err
fn (z: Tokenizer) err() -> Str?Go’s Err after an Error token: EOF at the end of the input, max buffer exceeded past the limit; None before one.
Tokenizer.allow_cdata
fn (var z: Tokenizer) allow_cdata(allow: Bool)Go’s AllowCDATA: <![CDATA[x]]> is the text x instead of a bogus
comment (default false).
Tokenizer.next_is_not_raw_text
fn (var z: Tokenizer) next_is_not_raw_text()Go’s NextIsNotRawText: the next token after a raw text start tag is scanned as ordinary markup.
Tokenizer.set_max_buf
fn (var z: Tokenizer) set_max_buf(n: Int)Go’s SetMaxBuf: a token longer than n bytes is an Error (0 is no limit).
Tokenizer.buffered
fn (z: Tokenizer) buffered() -> StrGo’s Buffered: the input not yet tokenized.
Functions
tokenizer
fn tokenizer(text: Str) -> TokenizerGo’s NewTokenizer.
tokenizer_fragment
fn tokenizer_fragment(text: Str, context_tag: Str) -> TokenizerGo’s NewTokenizerFragment: tokenizing the inner HTML of an element with
the tag context_tag (title and textarea start in RCDATA; style,
xmp, iframe, noembed, noframes, script, noscript, plaintext
in plain text).