hast-util-to-text
Advanced tools
Comparing version 1.0.1 to 2.0.0
{ | ||
"name": "hast-util-to-text", | ||
"version": "1.0.1", | ||
"description": "Get the plain-text value of a node according to the `innerText` algorithm", | ||
"version": "2.0.0", | ||
"description": "hast utility to get the plain-text value of a node according to the `innerText` algorithm", | ||
"license": "MIT", | ||
"keywords": [ | ||
"rehype", | ||
"unist", | ||
"hast", | ||
"unist", | ||
"hast-util", | ||
"util", | ||
"utility", | ||
"html", | ||
"string", | ||
"content", | ||
"text", | ||
"innertext" | ||
@@ -17,2 +20,6 @@ ], | ||
"bugs": "https://github.com/syntax-tree/hast-util-to-text/issues", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/unified" | ||
}, | ||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)", | ||
@@ -26,5 +33,5 @@ "contributors": [ | ||
"dependencies": { | ||
"hast-util-is-element": "^1.0.2", | ||
"repeat-string": "^1.6.1", | ||
"unist-util-find-after": "^2.0.3" | ||
"hast-util-is-element": "^1.0.0", | ||
"repeat-string": "^1.0.0", | ||
"unist-util-find-after": "^3.0.0" | ||
}, | ||
@@ -34,10 +41,10 @@ "devDependencies": { | ||
"hastscript": "^5.0.0", | ||
"nyc": "^14.0.0", | ||
"nyc": "^15.0.0", | ||
"prettier": "^1.0.0", | ||
"remark-cli": "^6.0.0", | ||
"remark-preset-wooorm": "^5.0.0", | ||
"remark-cli": "^7.0.0", | ||
"remark-preset-wooorm": "^6.0.0", | ||
"tape": "^4.0.0", | ||
"tinyify": "^2.0.0", | ||
"unist-builder": "^1.0.0", | ||
"xo": "^0.24.0" | ||
"unist-builder": "^2.0.0", | ||
"xo": "^0.27.0" | ||
}, | ||
@@ -44,0 +51,0 @@ "scripts": { |
@@ -11,3 +11,4 @@ # hast-util-to-text | ||
Get the plain-text value of a [hast][] node. | ||
[**hast**][hast] utility to get the plain-text value of a [*node*][node]. | ||
This is like the DOMs `Node#innerText` getter but there are some deviations from | ||
@@ -29,3 +30,3 @@ the spec. | ||
## Usage | ||
## Use | ||
@@ -60,9 +61,9 @@ ```js | ||
Get the plain-text value of a [node][]. | ||
Utility to get the plain-text value of a [*node*][node]. | ||
* If `node` is a comment, returns its `value` | ||
* If `node` is a text, applies normal white-space collapsing to its `value`, | ||
as defined by the [CSS Text][css] spec | ||
* If `node` is a root or element, applies an algorithm similar to the | ||
`innerText` getter as defined by [HTML][] | ||
* If `node` is a [*comment*][comment], returns its `value` | ||
* If `node` is a [*text*][text], applies normal white-space collapsing to its | ||
`value`, as defined by the [CSS Text][css] spec | ||
* If `node` is a [*root*][root] or [*element*][element], applies an algorithm | ||
similar to the `innerText` getter as defined by [HTML][] | ||
@@ -79,11 +80,19 @@ ###### Parameters | ||
* If an element is given that is not displayed (like a `head`), we’ll still | ||
use the `innerText` algorithm instead of switching to `textContent` | ||
* If child elements are not displayed, they will be ignored | ||
* CSS is not taken into account, except for the default user agent style sheet | ||
* If `node` is an [*element*][element] that is not displayed (such as a | ||
`head`), we’ll still use the `innerText` algorithm instead of switching to | ||
`textContent` | ||
* If [*descendants*][descendant] of `node` are [*elements*][element] that are | ||
not displayed, they are ignored | ||
* CSS is not considered, except for the default user agent style sheet | ||
* A line feed is collapsed instead of ignored in cases where Fullwidth, Wide, | ||
or Halfwidth East Asian Width characters are used, the same goes for a case | ||
with Chinese, Japanese, or Yi writing systems | ||
* Replaced elements are treated like normal elements | ||
* Replaced [*elements*][element] (such as `audio`) are treated like | ||
non-replaced *elements* | ||
## Security | ||
`hast-util-to-text` does not change the syntax tree so there are no | ||
openings for [cross-site scripting (XSS)][xss] attacks. | ||
## Related | ||
@@ -104,4 +113,4 @@ | ||
This project has a [Code of Conduct][coc]. | ||
By interacting with this repository, organisation, or community you agree to | ||
This project has a [code of conduct][coc]. | ||
By interacting with this repository, organization, or community you agree to | ||
abide by its terms. | ||
@@ -137,3 +146,3 @@ | ||
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg | ||
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg | ||
@@ -154,4 +163,2 @@ [chat]: https://spectrum.chat/unified/rehype | ||
[hast]: https://github.com/syntax-tree/hast | ||
[html]: https://html.spec.whatwg.org/#the-innertext-idl-attribute | ||
@@ -161,4 +168,18 @@ | ||
[to-string]: https://github.com/rehypejs/rehype-minify/tree/master/packages/hast-util-to-string | ||
[descendant]: https://github.com/syntax-tree/unist#descendant | ||
[hast]: https://github.com/syntax-tree/hast | ||
[node]: https://github.com/syntax-tree/hast#nodes | ||
[to-string]: https://github.com/rehypejs/rehype-minify/tree/master/packages/hast-util-to-string | ||
[root]: https://github.com/syntax-tree/hast#root | ||
[comment]: https://github.com/syntax-tree/hast#comment | ||
[text]: https://github.com/syntax-tree/hast#text | ||
[element]: https://github.com/syntax-tree/hast#element | ||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24000
178
+ Addedunist-util-find-after@3.0.0(transitive)
+ Addedunist-util-is@4.1.0(transitive)
- Removedunist-util-find-after@2.0.4(transitive)
- Removedunist-util-is@3.0.0(transitive)
Updatedhast-util-is-element@^1.0.0
Updatedrepeat-string@^1.0.0
Updatedunist-util-find-after@^3.0.0