Skip to content

v0.3.0

Latest

Choose a tag to compare

@github-actions github-actions released this 04 Apr 16:20

What's new

convert_rich/2 — annotated rich text output

Returns structured {text, [annotation]} tuples instead of plain text, enabling custom renderers (ANSI terminal, Slack, Discord, etc.).

HTML2Text.convert_rich("<p>Hello <strong>world</strong></p>")
#=> {:ok, [[{"Hello ", []}, {"world", [:strong]}]]}

Annotations: :strong, :emphasis, :strikeout, :code, {:link, url}, {:image, src}, {:preformat, bool}, {:colour, {r, g, b}}, {:bg_colour, {r, g, b}}.

CSS colour extraction supported via use_doc_css: true and css: "..." options.

HTML2Text.HTML — inspectable HTML container

A struct that renders HTML as formatted text with ANSI styles when inspected in IEx. Bold, italic, clickable links (OSC 8), CSS true color, and more — directly in your terminal.

%{body: HTML2Text.HTML.new("<p>Hello <strong>world</strong></p>")}
# In IEx: %{body: #HTML2Text.HTML<Hello **world**>}

empty_img_mode option

Controls how images without alt text are rendered: :ignore (default), {:replace, text}, or :filename.

Other changes

  • Update html2text Rust crate from 0.15.1 to 0.16.7 (rowspan support, <noscript> fix, <b> tag support, various bug fixes)
  • Add HTML2Text.Error custom exception for bang functions
  • Enable css feature for colour extraction