Kunde21 / markdownfmt

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

main: Don't shell out to 'diff' #45

Closed abhinav closed 1 year ago

abhinav commented 1 year ago

Follow up to #40 that makes a similar change to the markdownfmt executable.

Instead of shelling out to the 'diff' program, run diff inside the binary with pkg/diff, using filenames 'a/$file' and 'b/$file'.

Secondly, print the diff $file markdownfmt/$file message to stderr instead of stdout. I'm also okay with deleting this print statement completely, but I retained it to match the old behavior.

Combined, this does two things:

Example output on markdownfmt's README.md (without #44 where this is fixed).

diff README.md markdownfmt/README.md
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
-markdownfmt
-===========
+# markdownfmt

 Fork of github.com/shurcooL/markdownfmt that targets following additions:

@@ -8,8 +7,7 @@
[...snip...]