Skip to content

Why is rendered content wrapped with <article>...</article>? #347

Answered by rpaul-stripe
paulrudy asked this question in Q&A
Discussion options

You must be logged in to vote

We chose this as the default behavior because we wanted the top-level transform to return a single render tree node. It can easily be changed by overriding the document node in your Markdoc configuration. If you want Markdoc.transform to return an array that isn't wrapped in a tag (which Markdoc's React renderer will turn into a Fragment), you can use the following configuration:

import Markdoc from '@markdoc/markdoc';

const config = {
  nodes: {
    document: {...Markdoc.nodes.document, render: null}
  }
};

const doc = Markdoc.parse(example);
const output = Markdoc.transform(doc, config);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@paulrudy
Comment options

Answer selected by rpaul-stripe
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
Converted from issue

This discussion was converted from issue #345 on March 22, 2023 13:24.