Skip to content

Trouble with children in custom "admonition" plugin in compiler #2355

Answered by ChristianMurphy
Firgrep asked this question in Q&A
Discussion options

You must be logged in to vote

Focus on the distinction between what properties can be applied directly to node and which go on node.data
children is a property directly of node.
hProperties and hName are of node.data.
ref: https://github.com/syntax-tree/mdast#readme and https://github.com/syntax-tree/mdast-util-to-hast#fields-on-nodes

Those were flipped in a few spots causing bugs.
I'd highly recommend using TypeScript or JSDoc (with TypeScript validation) to help catch mismatch in object structures.
With the data put in the correct spot, it adds the elements as expected:

https://stackblitz.com/edit/github-qo53wd-7vuhzr?file=src%2FApp.js

source from sandbox
import { useEffect, useState } from 'react';
import * as run…

Replies: 1 comment 21 replies

Comment options

You must be logged in to vote
21 replies
@Firgrep
Comment options

@ChristianMurphy
Comment options

@Firgrep
Comment options

@ChristianMurphy
Comment options

Answer selected by Firgrep
@Firgrep
Comment options

@Firgrep
Comment options

@ChristianMurphy
Comment options

@Firgrep
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants