Newxp.HtmlUtils (newxp v0.1.1)

Copy Markdown

Utility functions for cleaning and transforming HTML content.

Summary

Functions

Apply core HTML cleaning transformations.

Remove italic and emphasis tags.

Functions

clean_html_content(html)

Apply core HTML cleaning transformations.

Removes <figure>, <table>, and <noscript> elements from the HTML string and returns the cleaned HTML.

Examples

html = "<p>Hello</p><figure><img/></figure>"
Newxp.HtmlUtils.clean_html_content(html)
# => "<p>Hello</p>"

convert_italic_and_emphasis_to_plain_text(html)

Remove italic and emphasis tags.

Strips <i> and <em> elements from the HTML string and returns the result.

Examples

html = "<p>Hello <em>world</em></p>"
Newxp.HtmlUtils.convert_italic_and_emphasis_to_plain_text(html)
# => "<p>Hello </p>"