Expand description
Parser-driven helpers for HTML <head> manipulation.
Replaces the previous str::find / str::replace patterns scattered
across the SEO, og_image, llm, ai, i18n, highlight, sbom,
atom, json_feed, and jsonld plugins (issues #538, #539, #540).
Three operations are exposed:
inject_before_head_close— append a payload immediately before the real</head>end-tag, never inside a<pre>/<code>/ comment /<script>template that happens to contain the literal</head>string.extract_head_meta— singlelol_htmlwalk that pulls the document<title>, the<html lang>attribute, and the existing<link rel="canonical">href in one pass.remove_canonical_links— strip every<link rel~="canonical">in<head>without disturbing non-canonical<link>elements or matching literals embedded in<pre>blocks.
All three guard against the standard str::find failure modes:
comments containing the literal markup, <pre> / <code> samples
that quote the same tag, attribute order and quoting variants, and
multiple matches in body content.
Structs§
- Head
Meta - Metadata extracted from the document
<head>in a single parser walk.
Functions§
- extract_
head_ meta - Extracts
{title, lang, canonical}fromhtmlin a singlelol_htmlpass. - inject_
before_ head_ close - Inserts
payloadimmediately before the real</head>end-tag. - remove_
canonical_ links - Removes every
<link rel~="canonical">element from the document. - replace_
canonical_ link - Replaces every existing
<link rel~="canonical">with a singlepayloadinjected just before</head>, in one parser pass.