Kunde21 / markdownfmt

Like gofmt, but for Markdown.
MIT License
55 stars 7 forks source link

render: Support custom formatters #38

Closed abhinav closed 2 years ago

abhinav commented 2 years ago

The renderer currently unconditionally reformats Go code samples, and only Go code samples.

There are a couple issues with this:

This proposes a new WithCodeFormatters option for the renderer. If used, this option replaces the list of code formatters used by the renderer.

Code formatters are matched by language, optionally with aliases. By default, only a formatter for "go" (with the alias "Go") is included -- this matches the prior behavior.

If WithCodeFormatters is called without any arguments, it disables code formatting completely.

karelbilek commented 2 years ago

To quickly explain - the original usage for this was mainly for go samples in code documentation.

I think the original behaviour doesn't need to be enabled by default... I think default behaviour should be to just not do any reformatting.

(I am surprised that Uber is using our stuff, but also happy! :D )

Btw maybe some added tests would be nice...

abhinav commented 2 years ago

I think the original behaviour doesn't need to be enabled by default... I think default behaviour should be to just not do any reformatting.

I can make that change if you both agree that that's desirable. I retained the original behavior mostly to keep this change backwards compatible.