Skip to content

Instantly share code, notes, and snippets.

@wfairclough
Forked from dergachev/pandoc2redmine.sh
Last active August 27, 2015 22:52
Show Gist options
  • Save wfairclough/235d97ae430ab6a29902 to your computer and use it in GitHub Desktop.
Save wfairclough/235d97ae430ab6a29902 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment