-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to externalize
hast-util-minify-whitespace
- Loading branch information
Showing
14 changed files
with
1,577 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore-scripts=true | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* hast utility to minify whitespace between elements. | ||
* | ||
* ## What is this? | ||
* | ||
* This package is a utility that can minify the whitespace between elements. | ||
* | ||
* ## When should I use this? | ||
* | ||
* You can use this package when you want to improve the size of HTML fragments. | ||
* | ||
* ## Use | ||
* | ||
* ```js | ||
* import {h} from 'hastscript' | ||
* import {minifyWhitespace} from 'hast-util-minify-whitespace' | ||
* | ||
* const tree = h('p', [ | ||
* ' ', | ||
* h('strong', 'foo'), | ||
* ' ', | ||
* h('em', 'bar'), | ||
* ' ', | ||
* h('meta', {itemProp: true}), | ||
* ' ' | ||
* ]) | ||
* | ||
* minifyWhitespace(tree) | ||
* | ||
* console.log(tree) | ||
* //=> h('p', [h('strong', 'foo'), ' ', h('em', 'bar'), h('meta', {itemProp: true})]) | ||
* ``` | ||
* | ||
* ## API | ||
* | ||
* ### `Options` | ||
* | ||
* Configuration (TypeScript type). | ||
* | ||
* ###### Fields | ||
* | ||
* * `newlines` (`boolean`, default: `false`) | ||
* — collapse whitespace containing newlines to `'\n'` instead of `' '` | ||
* (default: `false`); | ||
* the default is to collapse to a single space | ||
* | ||
* ###### Returns | ||
* | ||
* Nothing (`undefined`). | ||
* | ||
* ### `minifywhitespace(tree[, options])` | ||
* | ||
* Minify whitespace. | ||
* | ||
* ###### Parameters | ||
* | ||
* * `tree` (`Node`) — tree | ||
* * `options` (`Options`, optional) — configuration | ||
* | ||
* ###### Returns | ||
* | ||
* Nothing (`undefined`). | ||
*/ | ||
|
||
/** | ||
* @typedef {import('./lib/index.js').Options} Options | ||
*/ | ||
|
||
export {minifyWhitespace} from './lib/index.js' |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.