TidyEx v0.1.0-dev TidyEx

Elixir binding to the granddaddy of HTML tools http://www.html-tidy.org/. TidyEx corrects and cleans up HTML content by fixing markup errors.

Credits:

The package implements bindings to htacg’s tidy-html5. All tidy related features are implemeted in C using my wrapper library tidy_html. The Elixir binding is implemented as a C-Node based on the excellent example of Lukas Rieder’s nodex.

Example

iex> TidyEx.parse("<p>Hello World")
"<p>Hello World</p>"

Link to this section Summary

Functions

Clean and repair any string with valid or broken html. Returns valid html string

Serialize any string with valid or broken html. Returns valid html string

Internal use

Run diagnostics on string with valid or broken html. Returns diagnostics string

Link to this section Types

Link to this type error()
error() :: {:error, String.t()}
Link to this type input()
input() :: String.t() | [String.t()]
Link to this type success()
success() :: String.t() | [String.t()]

Link to this section Functions

Link to this function clean_and_repair(bin)
clean_and_repair(input()) :: success() | error()

Clean and repair any string with valid or broken html. Returns valid html string.

Examples

iex> TidyEx.clean_and_repair("<div>Hello<span>World")
"<div>Hello<span>World</span></div>"
Link to this function parse(bin)
parse(input()) :: success() | error()

Serialize any string with valid or broken html. Returns valid html string.

Examples

iex> TidyEx.parse("<div>Hello<span>World")
"<div>Hello<span>World</span></div>"

Internal use

Link to this function run_diagnostics(bin)
run_diagnostics(input()) :: success() | error()

Run diagnostics on string with valid or broken html. Returns diagnostics string.

Examples

iex> TidyEx.run_diagnostics("<pp>Hello World</p>")
"line 1 column 1 - Error: <pp> is not recognized!\nThis document has errors that must be fixed before\nusing HTML Tidy to generate a tidied up version."