Skip to content

[RFC] Creating a crate to parse code blocks ? #1033

@drupol

Description

@drupol

Hi there 👋

First of all, thank you for pulldown-cmark! It is a great library and its design makes it really easy to build Markdown tooling in Rust.

Markdown Code Runner is my very first Rust project. In it, I am using pulldown-cmark to process Markdown documents and execute embedded code blocks. I found the API flexible enough to build custom extractors by iterating over the events, but I ended up writing a lot of boilerplate just to filter and group fenced code blocks.

To simplify this, I implemented a small abstraction that wraps the iterator and yields CodeBlock structs containing the language, content, and optional attributes. The goal is to make working with code blocks as ergonomic as possible without re-parsing the document manually.

Would there be interest in creating a small companion crate (for example, something like pulldown-cmark-codeblock) that provides this iterator (and maybe more extractors in the future)? I would be happy to extract the logic and publish it if there is a need for this kind of utility.

Let me know what you think and if such an idea fits the ecosystem around pulldown-cmark.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions