Sha256: 336e497003b3597cc486ee276971fd10bd660e62c892bc890a45f24e4241bf01

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

# frozen_string_literal: true

module LiquidDiagrams
  module Renderers
    class MermaidRenderer < BasicRenderer
      OPTIONS = %w[
        theme
        width
        height
        backgroundColor
        configFile
        cssFile
        scale
      ].freeze

      def render
        Rendering.render_with_tempfile(build_command, @content) do |input, output|
          "--input #{input} --output #{output}"
        end
      end

      def build_command
        command = +'mmdc --puppeteerConfigFile '
        command << Utils.vendor_path('mermaid_puppeteer_config.json')

        @config.slice(*OPTIONS).each do |opt, value|
          command << " --#{opt} #{value}"
        end

        command
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
liquid-diagrams-0.3.0 lib/liquid_diagrams/renderers/mermaid_renderer.rb
liquid-diagrams-0.2.0 lib/liquid_diagrams/renderers/mermaid_renderer.rb
liquid-diagrams-0.1.0 lib/liquid_diagrams/renderers/mermaid_renderer.rb