Skip to content

Commit 2d9c098

Browse files
committedJul 24, 2024·
fix: remove hast-util-whitespace dependency
1 parent ed5a90e commit 2d9c098

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎src/lib/hastToRichText.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Element, Root } from "hast"
2-
import { whitespace } from "hast-util-whitespace"
32
import { toString } from "mdast-util-to-string"
43
import { visit } from "unist-util-visit"
54
import type { VFile } from "vfile"
@@ -274,7 +273,9 @@ export const hastToRichText = (
274273
throw error
275274
}
276275
} else if (node.type === "text") {
277-
if (!whitespace(node)) {
276+
// Inspired from `hast-util-whitespace`, see:
277+
// https://github.com/syntax-tree/hast-util-whitespace/blob/main/lib/index.js
278+
if (!(node.value.replace(/[ \t\n\f\r]/g, "") === "")) {
278279
try {
279280
builder.appendText(node.value)
280281
} catch (error) {

0 commit comments

Comments
 (0)
Please sign in to comment.