Wrap matches of regexp in the text of an HTML string with <mark> tags.
Only text nodes are searched, so tags, attribute names and attribute values
are left untouched. Text inside elements whose content isn't HTML text
(<script>, <style>, <textarea>, inline SVG and MathML, and the like) is
skipped, as is text in <pre> blocks, which syntax highlighters rebuild from
their plain text. Every match is wrapped when regexp has the global flag, otherwise
only the first one. When nothing matches, the HTML is returned exactly as it
was given.
The HTML is parsed into an inert <template>, so scripts don't run and
images don't load while it's being processed.
Wrap matches of
regexpin the text of an HTML string with<mark>tags.Only text nodes are searched, so tags, attribute names and attribute values are left untouched. Text inside elements whose content isn't HTML text (
<script>,<style>,<textarea>, inline SVG and MathML, and the like) is skipped, as is text in<pre>blocks, which syntax highlighters rebuild from their plain text. Every match is wrapped whenregexphas the global flag, otherwise only the first one. When nothing matches, the HTML is returned exactly as it was given.The HTML is parsed into an inert
<template>, so scripts don't run and images don't load while it's being processed.