-
Initial questionvar unified = require('unified')
var parse = require('remark-parse')
var english = require('retext-english')
var remark2retext = require('remark-retext')
var tree_from_md = unified().use(parse).use(remark2retext, english.Parser).parse('## Hello World')
var tree_from_text = unified().use(english).parse('Hello World') I would expect both
However, As I'm very new to unified, and unist in general, I'm sure what I'm observing is the expected behavior while I'm simply misunderstanding the documentation. So, essentially, what I'm looking for is how to retrieve an nlcst the output of Temporary solutionsThis solution requires me to include the following imports: var toNlcst = require('mdast-util-to-nlcst')
var vfile = require('vfile') I can run // Option 1
var tree_from_md = unified().use(parse).use(remark2retext, english.Parser).parse('## Hello World')
var nlcst_from_md = toNlcst(tree_from_md, vfile('## Hello World'), english.Parser)
// Option 2
var tree_from_direct_md = unified().use(parse).parse('## Hello World')
var nlcst_from_direct_md = toNlcst(tree_from_direct_md, vfile('## Hello World'), english.Parser) In either case, the first child of the tree is of type Happy holidays and many thanks to anyone who might happen to see this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi there! The And it’s good to see them as different processors: var processor = unified().use(parse).use(remark2retext, english.Parser)
var tree_from_md = processor.runSync(processor.parse(doc)) |
Beta Was this translation helpful? Give feedback.
Hi there!
The
.parse
function only performs the parsing stage..run
and.runSync
can be used to perform the run stage (running plugins).More info available here.
And it’s good to see them as different processors: