Skip to content

Instantly share code, notes, and snippets.

@dergachev
Created March 6, 2013 18:31
Show Gist options
  • Save dergachev/5101793 to your computer and use it in GitHub Desktop.
Save dergachev/5101793 to your computer and use it in GitHub Desktop.
pandoc2redmine.sh - wrapper script on pandoc to fix textile output for Redmine compatibility
#! /bin/env bash
cat $1 | ruby -pe 'puts " "*20 if $_.match("^```$")' \
| pandoc -f markdown -t textile \
| ruby -r CGI -n -e 'print CGI.unescapeHTML($_);' \
| ruby -ne 'puts $_ unless $_.match(" "*20)' \
| pbcopy
# without spaces, pandoc outputs "bc." for code blocks, which isn't accepted to redmine
# it also annoyingly HTML escapes its pre- block contents
# for more info, see https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Writers/Textile.hs#L136
# see http://johnmacfarlane.net/pandoc/README.html#bullet-lists for nested bullet syntax
@dergachev
Copy link
Author

Vim snippet:

1,$! ruby -pe 'puts " "*20 if $_.match("^```$")'   | pandoc -f markdown -t textile | ruby -r CGI -n -e 'print CGI.unescapeHTML($_);'  | ruby -ne 'puts $_ unless $_.match(" "*20)' 

@vpetro
Copy link

vpetro commented Mar 11, 2018

If you write with Github's markdown change markdown to gfm in the snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment