Skip to content

Discussion: support round trips? #892

@chriskrycho

Description

@chriskrycho

pulldown-cmark-to-cmark is a really handy crate for doing things like writing mdBook preprocessors, which I have been doing a bit of while working on The Rust Programming Language, but I have noticed that it is challenging for that crate to match the input precisely, and there are a fair number of subtle bugs that are (a) difficult for them to fix and therefore (b) require special handling in preprocessors using it, e.g. to manually re-insert newlines.

This is not a bug report, though, as I don’t think that kind of round-tripping was part of the design here! Rather, it is intended to start a discussion, on two axes:

  • Is supporting that kind of round-tripping desirable?
  • If so, what changes would be required to support it?
    • Maintaining original source spans (e.g. Provide Tag and Event source locations. #725)—but then how do you integrate that info when you insert new Events into a stream of Events (e.g. when rewriting in a preprocessor, extending behavior, etc.)?
    • Including list item types?
    • Including line wrapping for blockquotes?
    • etc.: I am sure there are a bunch of others

I think there are probably a bunch of open design questions there beyond just what would have to change, so, as I said: opening this for discussion and not assuming it is something the library should do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions