5 ms·
Markdownfmt – Like gofmt, but for Markdown
- programminggeek 12y agoCan someone make a fmtfmt, like gofmt but for fmt's? It might make it easier to just crank out one for your favorite language.
- shurcooL 12y agoI figured now was as good time as any to post this, after seeing jsfmt posted today. I've been dogfooding this for about a month for all my Markdown (mostly GitHub README.mds, comments to issues, etc.), and by now it's stable to cover my (admittedly, more basic) use cases of Markdown. I don't have explicit support for exotic Markdown features like tables at this time. The Atom package has 100+ downloads by now, and I've only had 1 issue reported so far, so I'd be very curious to actually learn how many other people use it.
- NateDad 12y agobtw, I don't know if it's just me, but I found it confusing that you had main.go in the subfolders... I generally assume main.go is only used in packages are that are executables, so it looked like the project had 3 executables in it.
- ihaveqvestion 12y agoThis seems interesting, but I'm not sure what formatting it would actually apply to a given Markdown document - could you add examples to the readme?
- shurcooL 12y agoI've made an example gif for the Atom package: https://raw.githubusercontent.com/shurcooL/atom-markdown-format/master/Demo.gif https://raw.githubusercontent.com/shurcooL/atom-markdown-for... There are also some examples in tests: https://github.com/shurcooL/markdownfmt/blob/d472cbc9d6118d67c4f6c8dabc498b2697be389d/markdown/main_test.go#L14-L51 https://github.com/shurcooL/markdownfmt/blob/d472cbc9d6118d6...
- dfc 12y agoI can live with condensing numbered lists and removing the blank lines between items. Unwrapping plain text paragraphs is worse but not the end of the world. We start to toe the line with unwrapping my blockquotes. You went way past that line when you removed the empty line at the end of the file.
- shurcooL 12y ago> Unwrapping plain text paragraphs is worse but not the end of the world. We start to toe the line with unwrapping my blockquotes. What do you mean by "unwrapping"? Can you give an example please. I don't think it should be doing any unwrapping; blockquotes should be preserved (and nicely formatted) [1]. > You went way past that line when you removed the empty line at the end of the file. It makes sure the last line has an ending newline, nothing more, nothing less. Any extra newlines are not visible in the generated HTML. [1] https://github.com/shurcooL/markdownfmt/blob/d472cbc9d6118d67c4f6c8dabc498b2697be389d/markdown/main_test.go#L94-L98 https://github.com/shurcooL/markdownfmt/blob/d472cbc9d6118d6...
- dfc 12y agoExample text (example.md): Alice wants to conduct a survey of her customers. She wants to restrict access to her customers (ie select subset of people) and she wants customers to be able to answer openly and not worry about reprisals. > Is there a magic token that Alice can distribute to her customers > (Bob,Carol,etc) that demonstrates their membership in survey pool and > protects the anonymity of their responses? Transcript: dfc@ronin:~$ wc example.md 8 67 395 example.md dfc@ronin:~$ .gopath/bin/markdownfmt example.md > gofmt.md dfc@ronin:~$ wc gofmt.md 3 65 390 gofmt.md dfc@ronin:~$ cat gofmt.md Alice wants to conduct a survey of her customers. She wants to restrict a**SNIP** > Is there a magic token that Alice can distribute to her customers (Bob,**SNIP** dfc@ronin:~$ I truncated the lines in the cat gofmt.md because long preformatted colums kill HN readability. That file was 7 lines of pristine markdown with a trailing newline. markdownfmt turned it into three lines total. dfc@ronin:~$ pandoc -t markdown -o pandoc.md example.md dfc@ronin:~$ wc pandoc.md 8 67 395 pandoc.md dfc@ronin:~$ I am not sure what you mean by "It makes sure the last line has an ending newline, nothing more, nothing less. Any extra newlines are not visible in the generated HTML." I thought this was a markdown formatting tool? Here is a hypothetical--but common--workflow that this destroys: Author keeps multiple chapters of book in separate files for easy editing and revision control. When it is time to publish text the author executes: $ cat 1.md 2.md 3.md 4.md |publishmd --some-options You killed my chapter titles.
- gte910h 12y agoCan/has someone do this for Objective C? Clang-Format doesn't do it like Apple and most programmers do, and nothing else comes close that I've seen.
- dfc 12y agoI am not sure I completely understand the use case but I am intrigued. I ran the following enough times that I finally aliased it to `prettymd`: $ pandoc -t markdown --atx-headers --no-wrap uglyfile.md That has been my go to way to clean up some of my crufty markdown formatting. I have a variant `spretyymd` that pipes the output to aspell. Obviously this does not replace the file in situ or create diffs. In situ pipe processing is always risky sounding enough that I never thought about doing it. I wish someone would write an updated par with better documentation.
- carterschonwald 12y agopandoc is AWESOME. Also pandoc actually got a haskell.org gsoc slot, which i'm really happy about (I helped make it happen)
- dfc 12y agoI can not say enough about pandoc. Atleast once I week I say "Why didn't you just pandoc -x -y -z it?" I am looking forward to the orgmode reader developments.
- carterschonwald 12y agoThis is actually the first summer pandoc got a gsoc student to! (via haskell.org umbrella org). A lot of great work will be landing this summer, including some neat support for URL encoded inline images (and a bunch of other great things)
- NateDad 12y agoThis is awesome. fmt all the things!