Ergonomic library for rewriting markdown documents?

Are there any ergonomic libraries for rewriting a markdown document?

I've got a changelog that follows the Keep a Changelog format and want to automate a couple boring operations:

  • Insert a new ## [v1.2.3] - 2020-02-03 header immediately after ## [Unreleased] to indicate a set of additions/changes/fixes are now part of the v1.2.3 release.

  • Add a new link definition for v1.2.3 so we can see the diff between it and the previous version (e.g. https://gitlab.com/my-company/my-project/compare/v1.2.2..v1.2.3).

  • Modify the link for [Unreleased] from "https://gitlab.com/my-company/my-project/compare/v1.2.2..master" to "https://gitlab.com/my-company/my-project/compare/v1.2.3..master".

I could bodge this together with regex, but I'd prefer to use a more robust solution if possible.

pulldown-cmark has a pretty nice iterator-y API for parsing/transforming Markdown. I believe that's the library rustdoc uses under the hood, so it's fairly battle-tested.

Yeah, I'm currently manipulating raw streams of Events from pulldown-cmark but the code gets quite gnarly after a while, with massive match statements and impromptu state machines.

I was looking for something a bit more high-level and ergonomic to use. Almost like jquery, or a DSL for building up the markdown equivalent of CSS selectors so you can apply the desired transformation.