Sha256: 317db46f8d9c453a6cf275ff3e5bbef46fd5d3e0e0ee69d1a674a9c291166744

Contents?: true

Size: 952 Bytes

Versions: 1

Compression:

Stored size: 952 Bytes

Contents

# frozen_string_literal: true

module Jekyll
  module Diagrams
    class BlockdiagBlock < Block
      CONFIGURATIONS = %w[config font fontmap size].freeze

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

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

      def read_config(context)
        config_for(context, 'blockdiag').merge(config_for(context, block_name))
      end

      def build_command(config)
        command = "#{block_name} -T svg --nodoctype"
        command << ' --antialias' if config.fetch('antialias', false) != false

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

        command
      end
    end
  end
end

%i[blockdiag seqdiag actdiag nwdiag rackdiag packetdiag].each do |tag|
  Liquid::Template.register_tag(tag, Jekyll::Diagrams::BlockdiagBlock)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-diagrams-0.9.2 lib/jekyll-diagrams/blockdiag.rb