洪 民憙 (Hong Minhee)'s avatar
洪 民憙 (Hong Minhee)

@hongminhee@hollo.social

I'm looking for a Markdown formatter, and I'm quite particular about my Markdown style. I don't want it to be formatted in a generic Markdown style. For instance, I prefer a style that adheres to rules such as:

  • 80 characters at most per line, except for code blocks and URLs.
  • Prefer reference links over inline links.
  • Prefer setext headings over ATX headings.
  • Two new lines before opening an H1/H2 heading.
  • One space before and two spaces after a bullet.
  • Wrap file paths in asterisks.
  • Wrap inline code in backticks.
  • Wrap code blocks in quadruple tildes (~~~~), and specify the language with a single space after the opening tildes (e.g., ~~~~ bash).

Are there any Markdown formatters that allow for such detailed customization of these elements? Or would I have to build one myself?

mtp's avatar
mtp

@matt@proud.social · Reply to 洪 民憙 (Hong Minhee)'s post

@hongminhee I have been interested in something similar (short on time to implement myself). The real challenge I found is finding an AST generating library for Markdown that supports re-emitting an altered AST as Markdown with fidelity.

Chee Aun 🤔's avatar
Chee Aun 🤔

@cheeaun@mastodon.social · Reply to 洪 民憙 (Hong Minhee)'s post

@hongminhee there are Markdown linters. There's a few of them and I know that Awesome lists use github.com/sindresorhus/awesom which uses github.com/remarkjs/remark-lint — the rules can get quite… annoying 🫣