pub struct MdxBodyEmitter { /* private fields */ }Expand description
Builds an MDX-runtime body - a _createMdxContent(props) function whose
return value is a React tree of jsx, jsxs, and Fragment. Imports +
exports hoist into a prelude; frontmatter is dropped.
Every container node is one expression with its kids inlined as a
comma-joined array, so we can’t interleave open/close text the way
HTML does. Instead each container open_frame pushes a child Frame;
kid expressions accumulate there as the walker descends; close_frame
pops, builds the parent expression, and folds it into the grandparent
frame.
Tables are emitted in one shot from enter Table (rows + cells aren’t
walker-visible Node variants); in_table_depth suppresses subsequent
walker events on cell content.
Owns its own DiagnosticEngine during the walk; merge into the
caller’s engine via into_parts after the walk completes.
Implementations§
Source§impl MdxBodyEmitter
impl MdxBodyEmitter
pub fn new() -> Self
Sourcepub fn render(doc: &Document) -> (String, DiagnosticEngine<Code>)
pub fn render(doc: &Document) -> (String, DiagnosticEngine<Code>)
Drive the walker; return (body, diag). Use when no other sink
shares the walk.
Sourcepub fn into_parts(self) -> (String, DiagnosticEngine<Code>)
pub fn into_parts(self) -> (String, DiagnosticEngine<Code>)
Take both buffers: the rendered MDX body and the per-emitter
diagnostic engine. Caller merges via outer.extend(diag).
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Wrap the accumulated body in the _createMdxContent shell and
prepend the import / export prelude. Drops the diagnostic engine.