unist utility to trace changes while processing
npm:
npm install unist-util-trace
To achieve optimal usage, employ the () => syntax
. Apply these tracepoints to the chain. Upon the initial call, only the tree is stored for comparison. Upon subsequent calls, it displays a diff relative to the previously saved unist tree.
.use(() => unistUtilTrace.diff()) // first call: save tree
//...
.use(() => unistUtilTrace.diff()) // second call: show diff
const { unistUtilTrace } = require("unist-util-trace")
const traceDiffSettings = {
reporter: ["unist-diff"]
}
module.exports = {
plugins: [
["remark-frontmatter", "yaml"],
[
"remark-retext",
unified()
.use(require("retext-english"))
.use(require("retext-syntax-urls"))
.use(() => unistUtilTrace.diff(traceDiffSettings)) // first to set tracepoint
.use(require("retext-syntax-mentions"), { style: /^@[\w-]{1,40}$/ })
.use(() => unistUtilTrace.diff(traceDiffSettings)) // second to see diffs from mentions
.use(require("retext-emoji"))
.use(() => unistUtilTrace.diff(traceDiffSettings)) // third to see diffs in retext-emoji
const traceDiffSettings = {
reporter: [ "unist-diff",
"diff-json",
"diff-inspect-full",
"diff-inspect-plain",
"json-diff-patch"
]
}
using unist-diff
using diff.json
using unist-util-inspect without options and then diff.diffLines
using unist-util-inspect with options for less noise and then diff.diffLines
using jsondiffpatch
with the console formatter
show a dot for each file
new line after 100 items
show current file name
newLine
: false -> change current linenewLine
: true -> each name on a new line
log all nodeType
nodes with inspect
run inspect
on the current tree
-
retext-syntax-mentions
— retext plugin to classify @mentions as syntax, not natural language -
retext-emoji
— retext plugin to support emoji, gemoji, and emoticons