Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
hast-util-to-text
Advanced tools
hast utility to get the plain-text value of a node according to the `innerText` algorithm
hast utility to get the plain-text value of a node.
This is like the DOMs Node#innerText
getter but there are some deviations from
the spec.
The resulting text is returned.
You’d typically want to use hast-util-to-string
(textContent
), but hast-util-to-text
(innerText
) adds for example line
breaks where <br>
elements are used.
This package is ESM only:
Node 12+ is needed to use it and it must be import
ed instead of require
d.
npm:
npm install hast-util-to-text
import {h} from 'hastscript'
import {toText} from 'hast-util-to-text'
const tree = h('div', [
h('h1', {hidden: true}, 'Alpha.'),
h('article', [
h('p', ['Bravo', h('br'), 'charlie.']),
h('p', 'Delta echo \t foxtrot.')
])
])
console.log(toText(tree))
Yields:
Bravo
charlie.
Delta echo foxtrot.
This package exports the following identifiers: toText
.
There is no default export.
toText(node, options?)
Utility to get the plain-text value of a node.
node
is a comment, returns its value
node
is a text, applies normal white-space collapsing to its
value
, as defined by the CSS Text specnode
is a root or element, applies an algorithm
similar to the innerText
getter as defined by HTMLoptions.whitespace
Default whitespace setting to use ('normal'
or 'pre'
, default: 'normal'
).
string
— Stringified node
.
node
is an element that is not displayed (such as a
head
), we’ll still use the innerText
algorithm instead of switching to
textContent
node
are elements that are
not displayed, they are ignoredaudio
) are treated like
non-replaced elementshast-util-to-text
does not change the syntax tree so there are no
openings for cross-site scripting (XSS) attacks.
hast-util-to-string
— Get the plain-text value (textContent
)hast-util-from-text
— Set the plain-text value (innerText
)hast-util-from-string
— Set the plain-text value (textContent
)See contributing.md
in syntax-tree/.github
for ways to get
started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
FAQs
hast utility to get the plain-text value of a node according to the `innerText` algorithm
The npm package hast-util-to-text receives a total of 687,992 weekly downloads. As such, hast-util-to-text popularity was classified as popular.
We found that hast-util-to-text demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.