module SyntaxTree::Mermaid

This module is responsible for rendering mermaid (mermaid.js.org/) flow charts.

Public Class Methods

escape(label) click to toggle source

Escape a label to be used in the mermaid syntax. This is used to escape HTML entities such that they render properly within the quotes.

# File lib/syntax_tree/mermaid.rb, line 158
def escape(label)
  "\"#{CGI.escapeHTML(label)}\""
end
flowchart() { |flowchart| ... } click to toggle source

Create a new flowchart. If a block is given, it will be yielded to and the flowchart will be rendered. Otherwise, the flowchart will be returned.

# File lib/syntax_tree/mermaid.rb, line 165
def flowchart
  flowchart = FlowChart.new

  if block_given?
    yield flowchart
    flowchart.render
  else
    flowchart
  end
end