markdownfmt
markdownfmt copied to clipboard
Badges and separate lines in the same paragraph
I ran this on some project READMEs, and one interesting case is what it does to the badges. When writing these out by hand, it's easy to put them on separate lines, without a blank line between them, which renders them in the same paragraph, and makes them easy to maintain. But the tool merges them to the same line, which doesn't seem desirable.
I understand what you're referring to.
I can suggest two alternatives that would work:
-
Have the badges on the same line, space separated. It's consistent with the rendering as HTML. It's what I do in most READMEs, including the one in this repository. Downside might be that they're harder to maintain, as you said, but I change badges infrequently.
-
Put 2 spaces at the end of each line to preserve the trailing newline. Like this:
[](https://travis-ci.org/...)<space><space> [](https://godoc.org/...)<space><space>
Where
<space>
is just a space (
Option 2 results in the badges on different lines. Is there a strong need to merge text in the same paragraph on different markdown lines?
You're right, option 2 will give different behavior.
It had to be done in some way. I considered it for some time:
https://github.com/shurcooL/markdownfmt/blob/f9ece38f23b0150fcfaa82de98ec43ce0b98a83e/markdown/main.go#L456
But ended up choosing to go without EXTENSION_HARD_LINE_BREAK
option.
It was mostly motivated by the desire to have manually wrapped text become automatically wrapped text, so that it would be readable even as you resize the width of your editor. E.g., this paragraph would become a normal paragraph instead of a narrow one.
Option 1 still works.
Do you want to reconsider that extension or expose a command-line flag?
I can reconsider the extension, but I won't be adding command-ling flags. I want to maintain the zero-configuration property of the formatting tool, just like gofmt
.
It will take me a while to think about whether that extension is a good idea. If you'd like to have it sooner, I suggest you make a fork and apply the change there for your own needs. That would be helpful, because you could also provide feedback on how well it works in your experience.
Thanks