Sha256: be04df208736fef6c3ffc42e9cfd8ddeb631e67bd8dae2e68521fc8c45c16143

Contents?: true

Size: 692 Bytes

Versions: 1

Compression:

Stored size: 692 Bytes

Contents

module Jekyll
  module Diagrams
    class SMCatBlock < Block
      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} -"
        end

        svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
      end

      def build_command(config)
        command = 'smcat'

        CONFIGURATIONS.each do |conf|
          command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
        end

        command
      end
    end
  end
end

Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-diagrams-0.9.1 lib/jekyll-diagrams/smcat.rb