Skip to content

Commit

Permalink
fix: remove hast-util-whitespace dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Jul 24, 2024
1 parent ed5a90e commit 2d9c098
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/hastToRichText.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Element, Root } from "hast"
import { whitespace } from "hast-util-whitespace"
import { toString } from "mdast-util-to-string"
import { visit } from "unist-util-visit"
import type { VFile } from "vfile"
Expand Down Expand Up @@ -274,7 +273,9 @@ export const hastToRichText = (
throw error
}
} else if (node.type === "text") {
if (!whitespace(node)) {
// Inspired from `hast-util-whitespace`, see:
// https://github.com/syntax-tree/hast-util-whitespace/blob/main/lib/index.js
if (!(node.value.replace(/[ \t\n\f\r]/g, "") === "")) {
try {
builder.appendText(node.value)
} catch (error) {
Expand Down

0 comments on commit 2d9c098

Please sign in to comment.