Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Feb 19, 2024
1 parent 209b390 commit 0441658
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,18 @@ md4w also provides a `mdToJSON` function to render the markdown to JSON.

```js
const traverse = (node) => {
// text node
if (typeof node === "string") {
// text node
console.log(node);
return;
}

// element type
console.log(node.type);

// element attributes (may be undefined)
console.log(node.props);

// element children (may be undefined)
node.children?.forEach(traverse);
};
Expand Down

0 comments on commit 0441658

Please sign in to comment.