hast-util-phrasing
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1,5 +0,1 @@ | ||
/** | ||
* @param {unknown} node | ||
* @returns {boolean} | ||
*/ | ||
export function phrasing(node: unknown): boolean | ||
export {phrasing} from './lib/index.js' |
73
index.js
@@ -1,72 +0,1 @@ | ||
import {convertElement} from 'hast-util-is-element' | ||
import {hasProperty} from 'hast-util-has-property' | ||
import {embedded} from 'hast-util-embedded' | ||
import {isBodyOkLink} from 'hast-util-is-body-ok-link' | ||
const basic = convertElement([ | ||
'a', | ||
'abbr', | ||
// `area` is in fact only phrasing if it is inside a `map` element. | ||
// However, since `area`s are required to be inside a `map` element, and it’s | ||
// a rather involved check, it’s ignored here for now. | ||
'area', | ||
'b', | ||
'bdi', | ||
'bdo', | ||
'br', | ||
'button', | ||
'cite', | ||
'code', | ||
'data', | ||
'datalist', | ||
'del', | ||
'dfn', | ||
'em', | ||
'i', | ||
'input', | ||
'ins', | ||
'kbd', | ||
'keygen', | ||
'label', | ||
'map', | ||
'mark', | ||
'meter', | ||
'noscript', | ||
'output', | ||
'progress', | ||
'q', | ||
'ruby', | ||
's', | ||
'samp', | ||
'script', | ||
'select', | ||
'small', | ||
'span', | ||
'strong', | ||
'sub', | ||
'sup', | ||
'template', | ||
'textarea', | ||
'time', | ||
'u', | ||
'var', | ||
'wbr' | ||
]) | ||
const meta = convertElement('meta') | ||
/** | ||
* @param {unknown} node | ||
* @returns {boolean} | ||
*/ | ||
export function phrasing(node) { | ||
return Boolean( | ||
// @ts-expect-error Looks like a node. | ||
(node && node.type === 'text') || | ||
basic(node) || | ||
embedded(node) || | ||
// @ts-expect-error Looks like a node. | ||
isBodyOkLink(node) || | ||
(meta(node) && hasProperty(node, 'itemProp')) | ||
) | ||
} | ||
export {phrasing} from './lib/index.js' |
{ | ||
"name": "hast-util-phrasing", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "hast utility to check if a node is phrasing content", | ||
@@ -31,2 +31,3 @@ "license": "MIT", | ||
"files": [ | ||
"lib/", | ||
"index.d.ts", | ||
@@ -36,2 +37,3 @@ "index.js" | ||
"dependencies": { | ||
"@types/hast": "^2.0.0", | ||
"hast-util-embedded": "^2.0.0", | ||
@@ -43,21 +45,19 @@ "hast-util-has-property": "^2.0.0", | ||
"devDependencies": { | ||
"@types/tape": "^4.0.0", | ||
"@types/node": "^18.0.0", | ||
"c8": "^7.0.0", | ||
"hastscript": "^7.0.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^10.0.0", | ||
"remark-cli": "^11.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"unist-builder": "^3.0.0", | ||
"xo": "^0.49.0" | ||
"xo": "^0.53.0" | ||
}, | ||
"scripts": { | ||
"prepack": "npm run build && npm run format", | ||
"build": "rimraf \"*.d.ts\" && tsc && type-coverage", | ||
"build": "tsc --build --clean && tsc --build && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"test-api": "node test.js", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js", | ||
"test-api": "node --conditions development test.js", | ||
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
@@ -64,0 +64,0 @@ }, |
@@ -20,3 +20,3 @@ # hast-util-phrasing | ||
* [API](#api) | ||
* [`phrasing(node)`](#phrasingnode) | ||
* [`phrasing(value)`](#phrasingvalue) | ||
* [Types](#types) | ||
@@ -42,3 +42,3 @@ * [Compatibility](#compatibility) | ||
This package is [ESM only][esm]. | ||
In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]: | ||
In Node.js (version 14.14+ and 16.0+), install with [npm][]: | ||
@@ -101,6 +101,6 @@ ```sh | ||
This package exports the identifier `phrasing`. | ||
This package exports the identifier [`phrasing`][phrasing]. | ||
There is no default export. | ||
### `phrasing(node)` | ||
### `phrasing(value)` | ||
@@ -111,7 +111,8 @@ Check if the given value is [*phrasing*][spec] content. | ||
* `node` (`*`) — Value to check, typically [`Node`][node]. | ||
* `value` (`unknown`) | ||
— thing to check, typically [`Node`][node] | ||
###### Returns | ||
Whether `node` passes the test (`boolean`). | ||
Whether `value` is phrasing content (`boolean`). | ||
@@ -127,3 +128,3 @@ ## Types | ||
versions of Node.js. | ||
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+. | ||
As of now, that is Node.js 14.14+ and 16.0+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
@@ -231,3 +232,3 @@ | ||
[spec]: https://html.spec.whatwg.org/#phrasing-content-2 | ||
[spec]: https://html.spec.whatwg.org/multipage/dom.html#phrasing-content-2 | ||
@@ -239,1 +240,3 @@ [hast]: https://github.com/syntax-tree/hast | ||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting | ||
[phrasing]: #phrasingvalue |
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
12309
10
7
101
236
5
+ Added@types/hast@^2.0.0