Class: Jekyll::Diagrams::MermaidBlock

Inherits:
Block
  • Object
show all
Defined in:
lib/jekyll-diagrams/mermaid.rb

Constant Summary collapse

CONFIGURATIONS =
%w( backgroundColor height theme width).freeze

Instance Method Summary collapse

Methods inherited from Block

#read_config, #render, #wrap_class

Methods included from Util

#config_for, #diagrams_config, #vendor_path

Methods included from Renderer

#render_with_command, #render_with_stdin, #render_with_stdin_stdout, #render_with_stdout, #render_with_tempfile

Instance Method Details

#build_command(config) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jekyll-diagrams/mermaid.rb', line 14

def build_command(config)
  command = 'mmdc'
  command << ' --transparent' if config.has_key?('transparent')
  command << " --puppeteerConfigFile #{vendor_path('mermaid_puppeteer_config.json')}"

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

  command
end

#render_svg(code, config) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/jekyll-diagrams/mermaid.rb', line 6

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

  render_with_tempfile(command, code) do |command, input, output|
    "#{command} --input #{input} --output #{output}"
  end
end