Hacker News new | ask | show | jobs
by dfc 4429 days ago
Is saying this is similar to an issue in goimport a sly way of saying markdownfmt "works on a file-by-file basis like gofmt; and as such it does not and cannot know that file a.go and b.go belong to the same package. Put another way, this is a user error for the tool as is."?

That explanation does not really make sense. I want markdownfmt to work on the file chapter1.md and the following day after editing chapter 2 I want to process chapter2.md. markdownfmt never needs to know and never will know that I use chapter1.md and chapter2.md together. When I am done I am going to feed chapter[1-X].md to another tool for publishing. But I cant because I used markdownfmt on a file by file basis and it damaged my files.

Every large book I have seen that uses markdown uses this chapter (or smaller) as file workflow. The biggest example that comes to mind is the progit book: https://github.com/progit/progit/tree/master/en

1 comments

I understand the problem, I'm thinking how to best solve it.

FWIW, the markdown files for all chapters in that book you've linked do not contain an extra newline at the end; there's only one (just like markdownfmt leaves it).

What about using something like cat, except one that inserts a newline between all the files it concatenates? That way the .md files can remain as they are.

You could also terminate each paragraph with a double-newline, instead of using that to separate them. That would fix the problem.