-
Hi, I am trying to extend mdast with some additional node types (corresponding to html nodes such as subscript, superscript etc.) and all is well except when using document fragments where the original html does not wrap all text in paragraphs, e.g. Stepping through the code it seems the issue lies in mdast-util-phrasing where any custom node fails the phrasing() in wrap.js resulting in wrapNeeded returning true and the custom node ending up getting wrapped separately. What is the correct way to extend the list of phrasing nodes to include the custom nodes?
Or am I barking up the wrong tree? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Specific to that project, it relates to “wrapping”: https://github.com/syntax-tree/hast-util-to-mdast/blob/main/lib/util/wrap.js. Right? That list currently, as you mention, uses One solution is to add an There is a similar list, What, if you attach HTML information to your custom nodes? That information is useful for the reverse process: https://github.com/syntax-tree/mdast-util-to-hast#fields-on-nodes. It makes sure your custom nodes integrate with many utilities that typically work with HTML. We could, when wrapping, look for this information, and compare it to |
Beta Was this translation helpful? Give feedback.
Specific to that project, it relates to “wrapping”: https://github.com/syntax-tree/hast-util-to-mdast/blob/main/lib/util/wrap.js. Right?
That list currently, as you mention, uses
mdast-util-phrasing
: phrasing nodes in mdast. That list currently can’t be extended.One solution is to add an
options.phrasing
. But, that’s probably so niche that it is not useful to many folks and if it would be useful to them, they probably wouldn’t find it.There is a similar list,
hast-util-phrasing
, which works on HTML tag names. The wrapping doesn’t operate on that, but it might be interesting.What, if you attach HTML information to your custom nodes? That information is useful for the reverse process: ht…