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§
- Html
Attribute - A lightweight HTML attribute.
- Html
Element - A lightweight HTML element view.
- Html
Heading - A lightweight heading extracted from
h1throughh6. - Html
Link - 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
hrefattributes. - 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
truewhen 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.