lib/jekyll/diagrams/diag.rb in jekyll-diagrams-0.2.1 vs lib/jekyll/diagrams/diag.rb in jekyll-diagrams-0.2.2

- old
+ new

@@ -2,24 +2,24 @@ require 'tempfile' module Jekyll module Diagrams class DiagBlock < Liquid::Block -     def initialize(tag_name, text, tokens) -        super -        @tag_name = tag_name -      end + def initialize(tag_name, text, tokens) + super + @tag_name = tag_name + end -      def render(context) -        config = context.registers[:site].config["diagrams"] + def render(context) + config = context.registers[:site].config["diagrams"] -        @renderer = DiagRenderer.new(config['diag']) + @renderer = DiagRenderer.new(config['diag']) -        render_diagram(super) -      end + render_diagram(super) + end -      private + private def render_diagram(code) @renderer.render(code, @tag_name) end end @@ -34,18 +34,18 @@ end def render(code, engine) tmp = Temfile.new(engine).path dest = "#{tmp}.svg" - + File.write(tmp, code) cmd = "#{engine} #{@config['options']} #{tmp} -o #{dest}" ret, status = Open3.capture2(cmd, binmode: true) - if !status.success? + if !status.success raise "Non-zero exit status '#{cmd}': #{status}" end - + svg = File.read(dest).force_encoding 'UTF-8' wrap_div(svg, engine) end