Sha256: 6ec9f2cf800f058a3b5c55d0f9ec43ac4427886e54c22e9fb6fa2ed37d9190c3

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

# frozen_string_literal: true

module Jekyll
  module Diagrams
    class ErdBlock < Block
      XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze
      CONFIGURATIONS = %w[config edge].freeze

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

        svg = render_with_stdin_stdout(command, code)
        svg.sub!(XML_REGEX, '')
      end

      def build_command(config)
        command = +'erd --fmt=svg'
        command << ' --dot-entity' if config.fetch('dot-entity', false) != false

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

        command
      end
    end
  end
end

Liquid::Template.register_tag(:erd, Jekyll::Diagrams::ErdBlock)

Version data entries

1 entries across 1 versions & 1 rubygems

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