Class: Jekyll::Diagrams::GraphvizRenderer
- Inherits:
-
BasicRenderer
- Object
- BasicRenderer
- Jekyll::Diagrams::GraphvizRenderer
- Defined in:
- lib/jekyll-diagrams/graphviz/renderer.rb
Constant Summary collapse
- XML_REGEX =
/^<\?xml(([^>]|\n)*>\n?){2}/.freeze
- CONFIGRATIONS =
{ 'K' => 'default_layout', 'G' => 'graph_attributes', 'N' => 'node_attributes', 'E' => 'edge_attributes' }.freeze
Instance Method Summary collapse
Methods inherited from BasicRenderer
Methods included from Rendering
render_with_command, render_with_stdin_stdout, render_with_tempfile
Constructor Details
This class inherits a constructor from Jekyll::Diagrams::BasicRenderer
Instance Method Details
#build_command(config) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# 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 |