Module mochiweb_html

Loosely tokenizes and generates parse trees for HTML 4.

Copyright © 2007 Mochi Media, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Authors: Bob Ippolito (bob@mochimedia.com).

Description

Loosely tokenizes and generates parse trees for HTML 4.

Data Types

end_tag()

end_tag() = {end_tag, Name}

html_attr()

html_attr() = {string(), string()}

html_comment()

html_comment() = {comment, Comment}

html_data()

html_data() = {data, string(), Whitespace::boolean()}

html_doctype()

html_doctype() = {doctype, [Doctype]}

html_node()

html_node() = {string(), [html_attr()], [html_node() | string()]}

html_token()

html_token() = html_data() | start_tag() | end_tag() | inline_html() | html_comment() | html_doctype()

inline_html()

inline_html() = {'=', iolist()}

start_tag()

start_tag() = {start_tag, Name, [html_attr()], Singleton::boolean()}

Function Index

escape/1Escape a string such that it's safe for HTML (amp; lt; gt;).
escape_attr/1Escape a string such that it's safe for HTML attrs (amp; lt; gt; quot;).
parse/1tokenize and then transform the token stream into a HTML tree.
parse_tokens/1Transform the output of tokens(Doc) into a HTML tree.
to_html/1Convert a list of html_token() to a HTML document.
to_tokens/1Convert a html_node() tree to a list of tokens.
tokens/1Transform the input UTF-8 HTML into a token stream.

Function Details

escape/1

escape(B::string() | atom() | binary()) -> binary()

Escape a string such that it's safe for HTML (amp; lt; gt;).

escape_attr/1

escape_attr(B::string() | binary() | atom() | integer() | float()) -> binary()

Escape a string such that it's safe for HTML attrs (amp; lt; gt; quot;).

parse/1

parse(Input::string() | binary()) -> html_node()

tokenize and then transform the token stream into a HTML tree.

parse_tokens/1

parse_tokens(Tokens::[html_token()]) -> html_node()

Transform the output of tokens(Doc) into a HTML tree.

to_html/1

to_html(Node::[html_token()] | html_node()) -> iolist()

Convert a list of html_token() to a HTML document.

to_tokens/1

to_tokens(T::html_node()) -> [html_token()]

Convert a html_node() tree to a list of tokens.

tokens/1

tokens(Input::StringOrBinary) -> [html_token()]

Transform the input UTF-8 HTML into a token stream.


Generated by EDoc