class Jekyll::Diagrams::GraphvizRenderer

Constants

CONFIGRATIONS
XML_REGEX

Public Instance Methods

build_command(config) click to toggle source
# File lib/jekyll-diagrams/graphviz/renderer.rb, line 24
def build_command(config)
  command = +'dot -Tsvg'

  CONFIGRATIONS.each do |prefix, conf|
    next unless config.key?(conf)

    command << Utils.normalized_attrs(
      config[conf],
      prefix: " -#{prefix}"
    )
  end

  command
end
render_svg(code, config) click to toggle source
# File lib/jekyll-diagrams/graphviz/renderer.rb, line 14
def render_svg(code, config)
  command = build_command(config)

  svg = render_with_stdin_stdout(command, code).force_encoding(
    config.fetch('encoding', 'utf-8')
  )

  svg.sub!(XML_REGEX, '')
end