Created
August 25, 2012 18:58
-
-
Save matze/3469301 to your computer and use it in GitHub Desktop.
Ditaa plugin for Jekyll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is superseded by this plugin.