Skip to content

Instantly share code, notes, and snippets.

@matze
Created August 25, 2012 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matze/3469301 to your computer and use it in GitHub Desktop.
Save matze/3469301 to your computer and use it in GitHub Desktop.
Ditaa plugin for Jekyll
require 'fileutils'
module Jekyll
class DitaaBlock < Liquid::Block
def initialize(tag_name, markup, tokens)
super
end
def render(context)
File.open('/tmp/ditaa.txt', 'w') {|f| f.write(super)}
result = system('ditaa /tmp/ditaa.txt -o /tmp/ditaa-foo.png')
if result
FileUtils.mv('/tmp/ditaa-foo.png', '_site/images/ditaa-foo.png')
output = '<img src="ditaa-foo.png" />'
output
else
''
end
end
end
end
Liquid::Template.register_tag('ditaa', Jekyll::DitaaBlock)
@matze
Copy link
Author

matze commented Aug 26, 2012

This is superseded by this plugin.

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