Sha256: d63a4c3dc3d567b4b0e2ebc34da83d19e4fb1fefcc09cbf4828ca8aec01af00b

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

module Jekyll
  module Diagrams
    class SyntraxBlock < Block
      CONFIGURATIONS = %w[scale style].freeze

      def render_svg(code, config)
        command = build_command(config)

        render_with_tempfile(command, code) do |input, output|
          "--input #{input} --output #{output}"
        end
      end

      def build_command(config)
        command = +'syntrax'

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

        command
      end
    end
  end
end

Liquid::Template.register_tag(:syntrax, Jekyll::Diagrams::SyntraxBlock)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-diagrams-0.9.3 lib/jekyll-diagrams/syntrax.rb
jekyll-diagrams-0.9.2 lib/jekyll-diagrams/syntrax.rb