# Title: PlantUML Code Blocks for Jekyll # Author: YJ Park (yjpark@gmail.com) # https://github.com/yjpark/jekyll-plantuml # Description: Integrate PlantUML into Jekyll and Octopress. # # Syntax: # {% plantuml %} # plantuml code # {% endplantuml %} # require 'open3' require 'fileutils' module Jekyll class PlantUMLBlock < Liquid::Block attr_reader :config def render(context) site = context.registers[:site] self.config = site.config['plantuml'] tmproot = File.expand_path(tmp_folder) folder = '/images/plantuml/' create_tmp_folder(tmproot, folder) code = @nodelist.join + background_color filename = Digest::MD5.hexdigest(code) + '.png' filepath = tmproot + folder + filename if !File.exist?(filepath) plantuml_jar = File.expand_path(plantuml_jar_path) cmd = 'java -Djava.awt.headless=true -jar ' + plantuml_jar + dot_cmd + ' -pipe > ' + filepath result, status = Open3.capture2e(cmd, :stdin_data=>code) Jekyll.logger.debug(filepath + " -->\t" + status.inspect() + "\t" + result) end site.static_files << Jekyll::StaticFile.new(site, tmproot, folder, filename) "