markupz (markupz v1.0.0)

View Source

Convert HTML fragments to Markdown or readable email text.

Summary

Functions

Safely convert HTML using the default preset.

Safely convert HTML using a preset or option map.

Convert an HTML email body to a readable text alternative.

Convert HTML using the default preset.

Convert HTML using a preset or an option map.

Types

html_option/0

-type html_option() :: keep | strip.

mode/0

-type mode() :: default | faithful | email.

option_input/0

-type option_input() :: mode() | options().

options/0

-type options() ::
          #{mode => mode(), html => html_option(), tables => table_option(), links => link_option()}.

reason/0

-type reason() :: invalid_unicode | {invalid_option, atom(), term()} | term().

table_option/0

-type table_option() :: markdown | text.

Functions

convert(Html)

-spec convert(iodata()) -> {ok, binary()} | {error, reason()}.

Safely convert HTML using the default preset.

convert(Html, Options0)

-spec convert(iodata(), option_input()) -> {ok, binary()} | {error, reason()}.

Safely convert HTML using a preset or option map.

to_email_text(Html)

-spec to_email_text(iodata()) -> binary().

Convert an HTML email body to a readable text alternative.

to_markdown(Html)

-spec to_markdown(iodata()) -> binary().

Convert HTML using the default preset.

Raises error({invalid_html, Reason}) if the input or options are invalid.

to_markdown(Html, Options)

-spec to_markdown(iodata(), option_input()) -> binary().

Convert HTML using a preset or an option map.

The default preset converts body content, omits ARIA-hidden elements, and flattens presentation tables. The faithful preset also includes document metadata and presentation HTML. The email preset strips unsupported HTML, removes hidden email content, and writes link destinations inline.