Skip to main content

Crate use_html

Crate use_html 

Source
Expand description

§use-html

Small HTML utility primitives for RustUse.

§Experimental

use-html is experimental while the use-web workspace remains below 0.3.0. Expect small API adjustments during the first release wave.

§Example

use use_html::{extract_links, extract_title, strip_tags_basic};

let html = "<html><head><title>Docs</title></head><body><a href=\"/guide\">Guide</a></body></html>";

assert_eq!(extract_title(html).as_deref(), Some("Docs"));
assert_eq!(extract_links(html)[0].href, "/guide");
assert_eq!(strip_tags_basic("<p>Hello <strong>world</strong></p>"), "Hello world");

§Scope

  • Lightweight HTML detection and string-based extraction helpers.
  • Small helpers for links, headings, titles, meta tags, and attributes.
  • Basic escaping and unescaping for common entities.

§Non-goals

  • Full HTML parsing.
  • DOM implementations.
  • Browser compatibility layers.
  • Sanitizers for security boundaries.

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Structs§

HtmlAttribute
A lightweight HTML attribute.
HtmlElement
A lightweight HTML element view.
HtmlHeading
A lightweight heading extracted from h1 through h6.
HtmlLink
A lightweight link extracted from an anchor tag.

Functions§

escape_html
Escapes common HTML-sensitive characters.
extract_attributes
Extracts attributes from an opening tag.
extract_headings
Extracts heading tags in document order.
extract_links
Extracts anchor tags with href attributes.
extract_meta_content
Extracts a <meta name="..." content="..."> value.
extract_title
Extracts the title text from the first <title> tag.
get_attribute
Returns the named attribute value from an element when present.
looks_like_html
Returns true when the input contains tag-like HTML markup.
strip_html_comments
Removes HTML comments from the input.
strip_tags_basic
Removes tag-like markup with simple angle-bracket stripping.
unescape_html
Unescapes common HTML entities.