|
Download wp-calypso/client/lib/highlight/README.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/highlight/README.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/highlight/README.md
-
curl -L -o README.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/highlight/README.md
710 Bytes
highlight
This module searches a given html string and wraps all matching strings with a <mark> or a custom wrapper.
If you give a custom element as a wrapper, it will be cloned every time it is added via cloneNode()
How to use
const html = '<div>hello world</div>';
const highlighted = highlight( 'hello', html );
Will produce:
<div><mark>hello</mark> world</div>
Using a custom highlight wrapper:
const customWrapper = document.createElement( 'span' );
customWrapper.setAttribute( 'class', 'my-wrapper' );
const customHighlighted = highlight( 'hello', html, customWrapper );
Will produce:
<div><span class="my-wrapper">hello</span> world</div>