Skip to content

Commit

Permalink
Add Pandoc formatter (#4)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alok authored and sbdchd committed Dec 5, 2016
1 parent 53d6bad commit 2860f18
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions autoload/neoformat/formatters/pandoc.vim
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions doc/neoformat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2860f18

Please sign in to comment.