lib/jekyll-diagrams/smcat.rb in jekyll-diagrams-0.9.1 vs lib/jekyll-diagrams/smcat.rb in jekyll-diagrams-0.9.2
- old
+ new
@@ -1,29 +1,32 @@
+# frozen_string_literal: true
+
module Jekyll
module Diagrams
class SMCatBlock < Block
- CONFIGURATIONS = %w( direction engine input-type ).freeze
+ 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, stdout: true) do |command, input|
- "#{command} #{input} -"
+ svg = render_with_tempfile(command, code, stdout: true) do |input|
+ "#{input} --output-to -"
end
- svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
+ svg.sub!(XML_REGEX, '')
end
def build_command(config)
- command = 'smcat'
+ command = +'smcat'
CONFIGURATIONS.each do |conf|
- command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
+ command << " --#{conf} #{config[conf]}" if config.key?(conf)
end
command
end
end
end
end
-Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)
\ No newline at end of file
+Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)