executablebooks / markdown-it-docutils

A markdown-it plugin for implementing docutils style roles/directives.
https://executablebooks.github.io/markdown-it-docutils/
MIT License
12 stars 8 forks source link

Remove unnecessary metadata on directive child #35

Open chrisjsewell opened 2 years ago

chrisjsewell commented 2 years ago

As just discussed, I don't think we need this any more, since you can retrieve this info from the (directive) parent node.

_Originally posted by @chrisjsewell in https://github.com/executablebooks/markdown-it-docutils/pull/34#discussion_r837792774_

fwkoch commented 2 years ago

I think if we are no longer copying meta from the directive to the parsed child, we still want to make sure we are copying all relevant attributes to the child nodes in the corresponding run methods. Although all the metadata will always be available on the parent directive, it's a hassle to have to walk back up the tree from the children to get it.

This PR does just that: https://github.com/executablebooks/markdown-it-docutils/pull/36

and is consumed in mystjs with this: https://github.com/executablebooks/mystjs/pull/40

In the end, with these ^^ we are basically doing the same thing as copying meta, it is just more explicit. We could also not copy attributes to the parsed children at all; this would just require a bit more management when going between directive parent <=> parsed child in mystjs.