Skip to content

Several markdown files concatted into one html file? #124

Answered by wooorm
dmca-glasgow asked this question in Q&A
Discussion options

You must be logged in to vote

you’re close! you can pass the vfile to parse, but also to run (and stringify), as the second parameter!

But indeed, unified is a pipeline for a single file, so here we’d need two:

const firstProcessor = unified()
  .use(remarkParse)
  .use(embedImages)
  // ..
  .use(remark2rehype)

// .parse and .run all markdown files, to get `hasts` (an array of HTML ASTs).

// Make that into a single HTML document
var hast = {type: 'root', children: hasts.flatMap(d => d.children)}

const secondProcessor = unified()
  // Use rehhype plugins that run on the whole document
  // ..
  .use(rehypeStringify)

// .run and .stringify the single `hast`. (or only stringify if there are no rehype plugins which s…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@wooorm
Comment options

@dmca-glasgow
Comment options

@wooorm
Comment options

@dmca-glasgow
Comment options

@wooorm
Comment options

Answer selected by dmca-glasgow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants