Documentation ¶
Overview ¶
Package html is an HTML5 lexer following the specifications at http://www.w3.org/TR/html5/syntax.html.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Hash ¶
type Hash uint32
Hash defines perfect hashes for a predefined list of strings
const ( A Hash = 0x1 // a Abbr Hash = 0x6e104 // abbr About Hash = 0x5 // about Accept Hash = 0x7106 // accept Accept_Charset Hash = 0x710e // accept-charset Accesskey Hash = 0x8309 // accesskey Acronym Hash = 0xed07 // acronym Action Hash = 0x2bd06 // action Address Hash = 0x6a407 // address Align Hash = 0x2e05 // align Alink Hash = 0x10405 // alink Allowfullscreen Hash = 0x2350f // allowfullscreen Alt Hash = 0x11d03 // alt Annotation Hash = 0x20d0a // annotation AnnotationXml Hash = 0x20d0d // annotationXml Applet Hash = 0x16a06 // applet Area Hash = 0x39504 // area Article Hash = 0x43007 // article Aside Hash = 0xa405 // aside Async Hash = 0x12905 // async Audio Hash = 0x14705 // audio Autocomplete Hash = 0x1530c // autocomplete Autofocus Hash = 0x15f09 // autofocus Autoplay Hash = 0x17408 // autoplay Axis Hash = 0x17c04 // axis B Hash = 0x101 // b Background Hash = 0x5d0a // background Base Hash = 0x3cc04 // base Basefont Hash = 0x3cc08 // basefont Bdi Hash = 0xfd03 // bdi Bdo Hash = 0x18503 // bdo Bgcolor Hash = 0x19807 // bgcolor Bgsound Hash = 0x1a707 // bgsound Big Hash = 0x1ba03 // big Blink Hash = 0x1bd05 // blink Blockquote Hash = 0x1c20a // blockquote Body Hash = 0x7f04 // body Border Hash = 0x33b06 // border Br Hash = 0x3402 // br Button Hash = 0x1cc06 // button Canvas Hash = 0xa006 // canvas Caption Hash = 0x28207 // caption Center Hash = 0x4e306 // center Challenge Hash = 0x1ed09 // challenge Charset Hash = 0x7807 // charset Checked Hash = 0x37f07 // checked Cite Hash = 0x12d04 // cite Class Hash = 0x1d705 // class Classid Hash = 0x1d707 // classid Clear Hash = 0x43405 // clear Code Hash = 0x1de04 // code Codebase Hash = 0x3c808 // codebase Codetype Hash = 0x1de08 // codetype Col Hash = 0x19a03 // col Colgroup Hash = 0x1f608 // colgroup Color Hash = 0x19a05 // color Cols Hash = 0x20804 // cols Colspan Hash = 0x20807 // colspan Command Hash = 0x21a07 // command Compact Hash = 0x22107 // compact Content Hash = 0x66e07 // content Contenteditable Hash = 0x66e0f // contenteditable Controls Hash = 0x22c08 // controls Coords Hash = 0x25306 // coords Crossorigin Hash = 0x25e0b // crossorigin Data Hash = 0x4c104 // data Datalist Hash = 0x4c108 // datalist Datatype Hash = 0x4d808 // datatype Datetime Hash = 0x2ed08 // datetime Dd Hash = 0x31902 // dd Declare Hash = 0xa707 // declare Default Hash = 0x4a07 // default DefaultChecked Hash = 0x50c0e // defaultChecked DefaultMuted Hash = 0x56f0c // defaultMuted DefaultSelected Hash = 0x4a0f // defaultSelected Defer Hash = 0x5805 // defer Del Hash = 0x9303 // del Desc Hash = 0x9d04 // desc Details Hash = 0xb307 // details Dfn Hash = 0xcf03 // dfn Dialog Hash = 0xfe06 // dialog Dir Hash = 0xdb03 // dir Dirname Hash = 0xdb07 // dirname Disabled Hash = 0x10b08 // disabled Div Hash = 0x11203 // div Dl Hash = 0x13302 // dl Download Hash = 0x49508 // download Draggable Hash = 0x1ad09 // draggable Dropzone Hash = 0x43b08 // dropzone Dt Hash = 0x60802 // dt Em Hash = 0xcb02 // em Embed Hash = 0xcb05 // embed Enabled Hash = 0x8d07 // enabled Enctype Hash = 0x2d207 // enctype Face Hash = 0x4e104 // face Fieldset Hash = 0x62a08 // fieldset Figure Hash = 0x29306 // figure Font Hash = 0x3d004 // font For Hash = 0x29f03 // for ForeignObject Hash = 0x29f0d // foreignObject Foreignobject Hash = 0x2ac0d // foreignobject Form Hash = 0x2b904 // form Formaction Hash = 0x2b90a // formaction Formenctype Hash = 0x2ce0b // formenctype Formmethod Hash = 0x2d90a // formmethod Formnovalidate Hash = 0x2e30e // formnovalidate Formtarget Hash = 0x2f80a // formtarget Frame Hash = 0xd305 // frame Frameborder Hash = 0x3360b // frameborder Frameset Hash = 0xd308 // frameset H1 Hash = 0x19602 // h1 H2 Hash = 0x32702 // h2 H3 Hash = 0x34c02 // h3 H4 Hash = 0x38e02 // h4 H5 Hash = 0x60a02 // h5 H6 Hash = 0x30202 // h6 Head Hash = 0x37404 // head Header Hash = 0x37406 // header Headers Hash = 0x37407 // headers Height Hash = 0x30406 // height Hgroup Hash = 0x30c06 // hgroup Hidden Hash = 0x31706 // hidden High Hash = 0x32404 // high Hr Hash = 0x13b02 // hr Href Hash = 0x13b04 // href Hreflang Hash = 0x13b08 // hreflang Html Hash = 0x30804 // html Http_Equiv Hash = 0x3290a // http-equiv I Hash = 0xa01 // i Icon Hash = 0x66d04 // icon Id Hash = 0xa602 // id Iframe Hash = 0x33506 // iframe Image Hash = 0x34105 // image Img Hash = 0x34603 // img Inert Hash = 0x55a05 // inert Inlist Hash = 0x26706 // inlist Input Hash = 0x48205 // input Ins Hash = 0x1b03 // ins Isindex Hash = 0x17e07 // isindex Ismap Hash = 0x34e05 // ismap Itemid Hash = 0x12e06 // itemid Itemprop Hash = 0x59208 // itemprop Itemref Hash = 0x62407 // itemref Itemscope Hash = 0x35809 // itemscope Itemtype Hash = 0x36208 // itemtype Kbd Hash = 0xfc03 // kbd Keygen Hash = 0x8906 // keygen Keytype Hash = 0x68d07 // keytype Kind Hash = 0x10804 // kind Label Hash = 0x9505 // label Lang Hash = 0x13f04 // lang Language Hash = 0x13f08 // language Legend Hash = 0x1b406 // legend Li Hash = 0x2f02 // li Link Hash = 0x10504 // link List Hash = 0x26904 // list Listing Hash = 0x4c507 // listing Longdesc Hash = 0x9908 // longdesc Loop Hash = 0x13404 // loop Low Hash = 0x23703 // low Main Hash = 0x1904 // main Malignmark Hash = 0xf30a // malignmark Manifest Hash = 0x68308 // manifest Map Hash = 0x16903 // map Mark Hash = 0xf904 // mark Marquee Hash = 0x36a07 // marquee Math Hash = 0x37104 // math Max Hash = 0x38603 // max Maxlength Hash = 0x38609 // maxlength Media Hash = 0xe005 // media Mediagroup Hash = 0xe00a // mediagroup Menu Hash = 0x3e604 // menu Meta Hash = 0x4d404 // meta Meter Hash = 0x2f305 // meter Method Hash = 0x2dd06 // method Mglyph Hash = 0x34706 // mglyph Mi Hash = 0x6b02 // mi Min Hash = 0x6b03 // min Mn Hash = 0x2e602 // mn Mo Hash = 0x4ff02 // mo Ms Hash = 0x35b02 // ms Mtext Hash = 0x39005 // mtext Multiple Hash = 0x39e08 // multiple Muted Hash = 0x3a605 // muted Name Hash = 0xde04 // name Nobr Hash = 0x3204 // nobr Noembed Hash = 0xc907 // noembed Noframes Hash = 0xd108 // noframes Nohref Hash = 0x13906 // nohref Noresize Hash = 0x24308 // noresize Noscript Hash = 0x31c08 // noscript Noshade Hash = 0x50707 // noshade Novalidate Hash = 0x2e70a // novalidate Nowrap Hash = 0x3ab06 // nowrap Object Hash = 0x2b306 // object Ol Hash = 0x19b02 // ol Onabort Hash = 0x1d007 // onabort Onafterprint Hash = 0x2870c // onafterprint Onbeforeprint Hash = 0x2c10d // onbeforeprint Onbeforeunload Hash = 0x6980e // onbeforeunload Onblur Hash = 0xbe06 // onblur Oncancel Hash = 0x14b08 // oncancel Oncanplay Hash = 0x18709 // oncanplay Oncanplaythrough Hash = 0x18710 // oncanplaythrough Onchange Hash = 0x45108 // onchange Onclick Hash = 0x6cb07 // onclick Onclose Hash = 0x3b707 // onclose Oncuechange Hash = 0x3ea0b // oncuechange Ondblclick Hash = 0x3f50a // ondblclick Ondrag Hash = 0x3ff06 // ondrag Ondragend Hash = 0x3ff09 // ondragend Ondragenter Hash = 0x4080b // ondragenter Ondragleave Hash = 0x4130b // ondragleave Ondragover Hash = 0x41e0a // ondragover Ondragstart Hash = 0x4280b // ondragstart Ondrop Hash = 0x43906 // ondrop Ondurationchange Hash = 0x44910 // ondurationchange Onemptied Hash = 0x44009 // onemptied Onended Hash = 0x45907 // onended Onerror Hash = 0x46007 // onerror Onfocus Hash = 0x46707 // onfocus Onhashchange Hash = 0x4740c // onhashchange Oninput Hash = 0x48007 // oninput Oninvalid Hash = 0x48709 // oninvalid Onkeydown Hash = 0x49009 // onkeydown Onkeypress Hash = 0x49d0a // onkeypress Onkeyup Hash = 0x4ac07 // onkeyup Onload Hash = 0x4b906 // onload Onloadeddata Hash = 0x4b90c // onloadeddata Onloadedmetadata Hash = 0x4cc10 // onloadedmetadata Onloadstart Hash = 0x4e90b // onloadstart Onmessage Hash = 0x4f409 // onmessage Onmousedown Hash = 0x4fd0b // onmousedown Onmousemove Hash = 0x51a0b // onmousemove Onmouseout Hash = 0x5250a // onmouseout Onmouseover Hash = 0x52f0b // onmouseover Onmouseup Hash = 0x53a09 // onmouseup Onmousewheel Hash = 0x5480c // onmousewheel Onoffline Hash = 0x55409 // onoffline Ononline Hash = 0x55f08 // ononline Onpagehide Hash = 0x5670a // onpagehide Onpageshow Hash = 0x57b0a // onpageshow Onpause Hash = 0x58707 // onpause Onplay Hash = 0x59e06 // onplay Onplaying Hash = 0x59e09 // onplaying Onpopstate Hash = 0x5a70a // onpopstate Onprogress Hash = 0x5b10a // onprogress Onratechange Hash = 0x5c00c // onratechange Onreset Hash = 0x5cc07 // onreset Onresize Hash = 0x5d308 // onresize Onscroll Hash = 0x5db08 // onscroll Onseeked Hash = 0x5e608 // onseeked Onseeking Hash = 0x5ee09 // onseeking Onselect Hash = 0x5f708 // onselect Onshow Hash = 0x60106 // onshow Onstalled Hash = 0x60c09 // onstalled Onstorage Hash = 0x61509 // onstorage Onsubmit Hash = 0x61e08 // onsubmit Onsuspend Hash = 0x63a09 // onsuspend Ontimeupdate Hash = 0x3d10c // ontimeupdate Onunload Hash = 0x64308 // onunload Onvolumechange Hash = 0x64b0e // onvolumechange Onwaiting Hash = 0x65909 // onwaiting Open Hash = 0x13604 // open Optgroup Hash = 0x66208 // optgroup Optimum Hash = 0x67d07 // optimum Option Hash = 0x69406 // option Output Hash = 0x206 // output P Hash = 0x501 // p Param Hash = 0x1505 // param Pattern Hash = 0x2507 // pattern Pauseonexit Hash = 0x5890b // pauseonexit Picture Hash = 0x3e07 // picture Ping Hash = 0xe904 // ping Placeholder Hash = 0x1fd0b // placeholder Plaintext Hash = 0x26e09 // plaintext Poster Hash = 0x31106 // poster Pre Hash = 0x35203 // pre Prefix Hash = 0x35206 // prefix Preload Hash = 0x3b007 // preload Profile Hash = 0x4b207 // profile Progress Hash = 0x5b308 // progress Prompt Hash = 0x54206 // prompt Property Hash = 0x59608 // property Public Hash = 0x66906 // public Q Hash = 0xae01 // q Radiogroup Hash = 0x350a // radiogroup Rb Hash = 0x5c02 // rb Readonly Hash = 0x39608 // readonly Rel Hash = 0x3b103 // rel Required Hash = 0xac08 // required Resource Hash = 0x29708 // resource Rev Hash = 0x4303 // rev Reversed Hash = 0x4308 // reversed Rows Hash = 0xc304 // rows Rowspan Hash = 0xc307 // rowspan Rp Hash = 0x28d02 // rp Rt Hash = 0x1d502 // rt Rtc Hash = 0x1d503 // rtc Ruby Hash = 0x12504 // ruby Rules Hash = 0x19e05 // rules S Hash = 0x1201 // s Samp Hash = 0x1204 // samp Sandbox Hash = 0x1d07 // sandbox Scope Hash = 0x35c05 // scope Scoped Hash = 0x35c06 // scoped Script Hash = 0x31e06 // script Scrolling Hash = 0x5dd09 // scrolling Seamless Hash = 0x3bc08 // seamless Section Hash = 0xb907 // section Select Hash = 0x5f906 // select Selected Hash = 0x5f908 // selected Shape Hash = 0x1a205 // shape Size Hash = 0x24704 // size Sizes Hash = 0x24705 // sizes Small Hash = 0x23305 // small Sortable Hash = 0x24b08 // sortable Source Hash = 0x29906 // source Spacer Hash = 0x25806 // spacer Span Hash = 0xc604 // span Spellcheck Hash = 0x37a0a // spellcheck Src Hash = 0x3c303 // src Srcdoc Hash = 0x3c306 // srcdoc Srclang Hash = 0x46d07 // srclang Srcset Hash = 0x4a606 // srcset Start Hash = 0x42e05 // start Step Hash = 0x26b04 // step Strike Hash = 0x68906 // strike Strong Hash = 0x5ba06 // strong Style Hash = 0x6aa05 // style Sub Hash = 0x62003 // sub Summary Hash = 0x6af07 // summary Sup Hash = 0x6b603 // sup Svg Hash = 0x6b903 // svg System Hash = 0x6bc06 // system Tabindex Hash = 0x708 // tabindex Table Hash = 0x24e05 // table Target Hash = 0x2fc06 // target Tbody Hash = 0x7e05 // tbody Td Hash = 0xda02 // td Template Hash = 0x6bf08 // template Text Hash = 0x27304 // text Textarea Hash = 0x39108 // textarea Tfoot Hash = 0x11f05 // tfoot Th Hash = 0x19002 // th Thead Hash = 0x37305 // thead Time Hash = 0x2f104 // time Title Hash = 0x16f05 // title Tr Hash = 0x22702 // tr Track Hash = 0x22705 // track Translate Hash = 0x27609 // translate Truespeed Hash = 0x63109 // truespeed Tt Hash = 0x2702 // tt Type Hash = 0x11904 // type Typemustmatch Hash = 0x1e20d // typemustmatch Typeof Hash = 0x4dc06 // typeof U Hash = 0x301 // u Ul Hash = 0x4e02 // ul Undeterminate Hash = 0x640d // undeterminate Usemap Hash = 0x16606 // usemap Valign Hash = 0x2d06 // valign Value Hash = 0x11405 // value Valuetype Hash = 0x11409 // valuetype Var Hash = 0x33203 // var Video Hash = 0x6c705 // video Visible Hash = 0x6d207 // visible Vlink Hash = 0x6d905 // vlink Vocab Hash = 0x6de05 // vocab Wbr Hash = 0x58403 // wbr Width Hash = 0x60605 // width Wrap Hash = 0x3ad04 // wrap Xmlns Hash = 0xe05 // xmlns Xmp Hash = 0x2303 // xmp )
Unique hash definitions to be used instead of strings
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer is the state for the lexer.
func NewLexer ¶
NewLexer returns a new Lexer for a given io.Reader.
Example ¶
l := NewLexer(bytes.NewBufferString("<span class='user'>John Doe</span>")) out := "" for { tt, data := l.Next() if tt == ErrorToken { break } out += string(data) } fmt.Println(out)
Output: <span class='user'>John Doe</span>
func (*Lexer) AttrVal ¶
AttrVal returns the attribute value when an AttributeToken was returned from Next.
func (*Lexer) Err ¶
Err returns the error encountered during lexing, this is often io.EOF but also other errors can be returned.
func (*Lexer) Next ¶
Next returns the next Token. It returns ErrorToken when an error was encountered. Using Err() one can retrieve the error message.
type TokenType ¶
type TokenType uint32
TokenType determines the type of token, eg. a number or a semicolon.