Kunde21 / markdownfmt

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

Don't reformat code blocks by default #56

Closed abhinav closed 1 year ago

abhinav commented 1 year ago

This is a follow up to #38 where @karelbilek brought up that we shouldn't reformat source code blocks by default at all.

With this change, fenced code blocks tagged with Go or go will no longer be formatted with gofmt by default. Users are expected to opt-into this functionality.

When using markdownfmt as a library, users can opt-in by adding the following option.

WithCodeFormatters(GoCodeFormatter)

When using markdownfmt as a binary, users can opt-in by adding the following flag:

-gofmt

For integration tests, I changed example1.input/output to have incorrectly formatted Go code, and added separate gofmt-input/output files to test behavior with the GoCodeFormatter enabled.

Resolves #46