lib/jekyll-diagrams/smcat.rb in jekyll-diagrams-0.9.3 vs lib/jekyll-diagrams/smcat.rb in jekyll-diagrams-0.10.0

- old
+ new

@@ -1,32 +1,10 @@ # frozen_string_literal: true +require_relative 'smcat/renderer' +require_relative 'smcat/block' + module Jekyll module Diagrams - class SMCatBlock < Block - XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze - CONFIGURATIONS = %w[direction engine input-type].freeze - - def render_svg(code, config) - command = build_command(config) - - svg = render_with_tempfile(command, code) do |input, output| - "#{input} --output-to #{output}" - end - - svg.sub!(XML_REGEX, '') - end - - def build_command(config) - command = +'smcat' - - CONFIGURATIONS.each do |conf| - command << " --#{conf} #{config[conf]}" if config.key?(conf) - end - - command - end - end + Liquid::Template.register_tag(:smcat, SMCatBlock) end end - -Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)