Class: Jekyll::Converters::Graphviz

Inherits:
Converter
  • Object
show all
Defined in:
lib/jekyll/converters/graphviz.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



9
10
11
# File 'lib/jekyll/converters/graphviz.rb', line 9

def cache
  @cache
end

Instance Method Details

#convert(content) ⇒ Object



27
28
29
30
# File 'lib/jekyll/converters/graphviz.rb', line 27

def convert(content)
  setup unless @setup
  @cache[content] ||= GraphViz.parse_string(content).output(@format => String)
end

#matches(ext) ⇒ Object



18
19
20
# File 'lib/jekyll/converters/graphviz.rb', line 18

def matches(ext)
  ext =~ /^\.dot$/i
end

#output_ext(ext) ⇒ Object



22
23
24
25
# File 'lib/jekyll/converters/graphviz.rb', line 22

def output_ext(ext)
  setup unless @setup
  ".#{@format}"
end

#setupObject



11
12
13
14
15
16
# File 'lib/jekyll/converters/graphviz.rb', line 11

def setup
  require 'ruby-graphviz'
  @format = (@config.dig("graphviz", "format") || :svg).to_sym
  @cache = {}
  @setup = true
end