module IO
Usage
import lang::html::IO;
Dependencies
extend lang::html::AST;
import Content;
Synopsis
Provides read and write functionality for HTMLElements defined in AST
data HTMLEscapeMode
data HTMLEscapeMode
= baseMode()
| extendedMode()
| xhtmlMode()
;
data HTMLSyntax
data HTMLSyntax
= htmlSyntax()
| xmlSyntax()
;
function readHTMLFile
Synopsis
Parse a HTML file and return an HTMLElement AST
Description
This function uses JSoup's HTML parser which is robust against errors in the HTML, and complete in the sense that it supports all of HTML.
HTMLElement readHTMLFile(loc file, loc base=file)
function readHTMLString
Synopsis
Parse a HTML string and return an HTMLElement AST
Description
This function uses JSoup's HTML parser which is robust against errors in the HTML, and complete in the sense that it supports all of HTML.
HTMLElement readHTMLString(str content, loc base=|http://localhost|)
function writeHTMLString
Synopsis
Pretty-print the HTMLElement AST to a string
Description
This function uses JSoup's DOM functionality to yield a syntactically correct (X)HTML string.
str writeHTMLString(HTMLElement dom, str charset="UTF-8", HTMLEscapeMode escapeMode = baseMode(), bool outline=false, bool prettyPrint=true, int indentAmount=4, int maxPaddingWidth=30, HTMLSyntax \syntax=htmlSyntax())
function writeHTMLFile
Synopsis
Pretty-print the HTMLElement AST to a string
Description
This function uses JSoup's DOM functionality to yield a syntactically correct (X)HTML file.
void writeHTMLFile(loc file, HTMLElement dom, str charset="UTF-8", HTMLEscapeMode escapeMode = baseMode(), bool outline=false, bool prettyPrint=true, int indentAmount=4, int maxPaddingWidth=30, HTMLSyntax \syntax=htmlSyntax())
function serve
Synopsis
Convenience function to visualize an HTMLElement tree in the browser
Content serve(HTMLElement elem)