Sha256: 5cc1d5b75198749817768778bc624e62cc1c160fa680a28230074b093cecd4bb
Contents?: true
Size: 1016 Bytes
Versions: 1
Compression:
Stored size: 1016 Bytes
Contents
module Jekyll module Diagrams class GraphvizBlock < Block CONFIGRATIONS = { 'K' => 'default_layout', 'G' => 'graph_attribute', 'N' => 'node_attribute', 'E' => 'edge_attribute' }.freeze def render_svg(code, config) svg = render_with_stdin_stdout(build_command(config), code) svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '') end def build_command(config) command = 'dot -Tsvg' CONFIGRATIONS.each do |prefix, conf| next unless config.has_key?(conf) attrs = config[conf] attrs = case attrs when String attrs when Array attrs.join(" -#{prefix}") when Hash attrs.map { |k, v| "#{k}=#{v}" }.join(" -#{prefix}") end command << " -#{prefix}#{attrs}" end command end end end end Liquid::Template.register_tag(:graphviz, Jekyll::Diagrams::GraphvizBlock)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jekyll-diagrams-0.7.1 | lib/jekyll-diagrams/graphviz.rb |