From 2860f180e3697c2f15b4e1e9bc818bc63202af1d Mon Sep 17 00:00:00 2001 From: Alok Singh Date: Sun, 4 Dec 2016 18:37:50 -0800 Subject: [PATCH] Add Pandoc formatter (#4) We can use Pandoc to format Pandoc-flavored Markdown. The extra flags handle bare URLs not being escaped correctly and non-standard Markdown headers. We pipe to `sed` to fix incorrect bracket escaping since Pandoc does not support the check box feature of Github Markdown. --- README.md | 2 ++ autoload/neoformat/formatters/pandoc.vim | 16 ++++++++++++++++ doc/neoformat.txt | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 autoload/neoformat/formatters/pandoc.vim diff --git a/README.md b/README.md index 085a80ec..2a50fe06 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,8 @@ let &verbose = 1 " also increases verbosity of the editor as a whole [`astyle`](http://astyle.sourceforge.net) - OCaml - [`ocp-indent`](http://www.typerex.org/ocp-indent.html) +- Pandoc Markdown + - [`pandoc`][https://pandoc.org/MANUAL.html] - Pawn - [`uncrustify`](http://uncrustify.sourceforge.net) - Perl diff --git a/autoload/neoformat/formatters/pandoc.vim b/autoload/neoformat/formatters/pandoc.vim new file mode 100644 index 00000000..5909b261 --- /dev/null +++ b/autoload/neoformat/formatters/pandoc.vim @@ -0,0 +1,16 @@ +function! neoformat#formatters#pandoc#enabled() abort + return ['pandoc'] +endfunction + +function! neoformat#formatters#pandoc#pandoc() abort + return { + \ 'exe': 'pandoc', + \ 'args': ['-f markdown+autolink_bare_uris', + \ '-t markdown+autolink_bare_uris', + \ '--atx-headers', + \ '%:p', + \ '|', + \ "sed -e 's/\\\[/[/g'", "-e 's/\\\]/]/g'",], + \ 'no_append': 1 + \ } +endfunction diff --git a/doc/neoformat.txt b/doc/neoformat.txt index d5c1a0eb..9e32db1f 100644 --- a/doc/neoformat.txt +++ b/doc/neoformat.txt @@ -126,6 +126,8 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes* [astyle](http://astyle.sourceforge.net) - OCaml - [ocp-indent](http://www.typerex.org/ocp-indent.html) +- Pandoc Markdown + - [pandoc][https://pandoc.org/MANUAL.html] - Pawn - [uncrustify](http://uncrustify.sourceforge.net) - Perl