Closed teythoon closed 1 month ago
At this time, I think I'd rather avoid heuristics as we can easily get things wrong. You are welcome to explore these ideas in helpers built on top and we can see what the ecosystem ends up settling on.
I don't understand. Heuristics can be wrong, but the status quo is always wrong.
Heuristics can be hard to predict and don't work as well in APIs.
I noticed that all the decor seems to be ending up in
prefix
and top-leveltrailing
. This unfortunately messes up the document when removing sections. Consider:This prints:
To be explicit:
foo
, the document's top-level comment is gone, and the sample entry for sectionfoo
is not removed.bar
, the sample entry for sectionfoo
is gone, and the sample entry for sectionbar
is wrongly placed below the sectionfoo
I think this could be improved by introducing a heuristic that splits the decor at paragraphs (i.e.
\n\n
), and associates parts of it with other nodes in the document tree.