Htmlparser is a listed [LuaRock](http://luarocks.org/repositories/rocks/). Install using [LuaRocks](http://www.luarocks.org/): `luarocks install htmlparser`
Htmlparser depends on [Lua 5.2](http://www.lua.org/download.html), and on the ["set"][1] LuaRock, which is installed along automatically. To be able to run the tests, [lunitx](https://github.com/dcurrie/lunit) also comes along as a LuaRock
The root element is a container for the top level elements in the parsed text, i.e. the `<html>` element in a parsed html document would be a child of the returned root element.
Supported selectors are a subset of [jQuery's selectors][2]:
-`"*"` all contained elements
-`"element"` elements with the given tagname
-`"#id"` elements with the given id attribute value
-`".class"` elements with the given classname in the class attribute
-`"[attribute]"` elements with an attribute of the given name
-`"[attribute='value']"` equals: elements with the given value for the attribute with the given name
-`"[attribute!='value']"` not equals: elements without an attribute of the given name, or with that attribute, but with a value that is different from the given value
-`"[attribute|='value']"` prefix: attribute's value is given value, or starts with given value, followed by a hyphen (`-`)
-`"[attribute*='value']"` contains: attribute's value contains given value
-`"[attribute~='value']"` word: attribute's value is a space-separated token, where one of the tokens is the given value
-`"[attribute^='value']"` starts with: attribute's value starts with given value
-`"[attribute$='value']"` ends with: attribute's value ends with given value
-`"ancestor descendant"` elements selected by the `descendant` selector string, that are a descendant of any element selected by the `ancestor` selector string
-`"parent > child"` elements selected by the `child` selector string, that are a child element of any element selected by the `parent` selector string
-`.deepernodes` a [Set][1] containing all elements in the tree beneath this element, including this element's `.nodes`; `{}` if none
-`.deeperelements` a table with a key for each distinct tagname in `.deepernodes`, containing a [Set][1] of all deeper element nodes with that name; `{}` in none
-`.deeperattributes` as `.deeperelements`, but keyed on attribute name
-`.deeperids` as `.deeperelements`, but keyed on id value
-`.deeperclasses` as `.deeperelements`, but keyed on class name
- Attribute values in selectors currently cannot contain any spaces, since space is interpreted as a delimiter between the `ancestor` and `descendant`, `parent` and `>`, or `>` and `child` parts of the selector
- Consequently, for the `parent > child` relation, the spaces before and after the `>` are mandatory
- Attribute values in selectors currently also cannot contain any of `#`, `.`, `[`, `]`, `:`, `(`, or `)`
-`<!` elements are not parsed, including doctype, comments, and CDATA
- Textnodes are not seperate entries in the tree, so the content of `<p>line1<br />line2</p>` is plainly `"line1<br />line2"`
- All start and end tags should be explicitly specified in the text to be parsed; omitted tags (as [permitted](http://www.w3.org/TR/html5/syntax.html#optional-tags) by the the HTML spec) are NOT implied. Only the [void](http://www.w3.org/TR/html5/syntax.html#void-elements) elements naturally don't need (and mustn't have) an end tag
- The HTML text is not validated in any way; tag and attribute names and the nesting of different tags is completely arbitrary. The only HTML-specific part of the parser is that it knows which tags are void elements