Skip to content

contrib(fmt): my yearning for a maudfmt#479

Description

@Jeosas

Hi there 馃惐

I really love the way maud is making html templating in rust so easy and practical. It reminds me a lot of why I liked elm's syntax so much, and its pretty much an emmet on steroid - without the useless expanding.

Though as much as like writing maud macros, the formatting is such a pain having to manage it manually. I see that I am not the only one in the issues, with eboody even implementing an elegant nvim plugin in #473 for this purpose.

When I take a look around, I see that some neighbors like leptos implemented their own leptosfmt that runs alongside rustfmt to specifically format their macro blocks.
I'd love to have something similar as a binary formatter that is reliable and could be used in any editor or in pre-commit/CI.
I was sold: I'm gonna build maudfmt.

I started implementing the thing, parsing maud::html with syn and reproducing maud's ast, but I got a bit uneasy:

  • the ast parser is already implemented in the maud_macros crate, and though available on crates.io the ast parser is private and unusable.
  • on top of having to re-implement the entire maud ast parser, I'd have to keep it in sync with maud's implementation (though I agree it shouldn't move much)

My questions are:

  • would it be possible to somehow make maud's ast parser publicly available so I could use it in a maudfmt crate ?
  • else, would it be reasonable to ask if maudfmt could be developed in the upstream maud repo so we could share the ast parser in a mutual dependency crate ?

Other options I consider, though way dirtier:

  • using a github submodules (better for staying synced with upstream, but doesn't fix the parser being private issue)
  • copy the code I need like a little thief and use it in my crate (staying sync will suck)

Stating the obvious, I am more than willing to create/contribute/maintain maudfmt whatever the solution agreed upon is.

Thus I'd like your insights on the matter.

Thank you for taking the time to read my little story.
Have a nice rest of your day/morning/night. 馃憢

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions