Class: Gollum::Filter::WSD

Inherits:
Gollum::Filter show all
Defined in:
lib/gollum-lib/filter/wsd.rb

Overview

Web Sequence Diagrams

Render an inline web sequence diagram by sending the WSD code through the online renderer available from www.websequencediagrams.com.

Constant Summary collapse

WSD_URL =
"http://www.websequencediagrams.com/index.php"

Instance Method Summary collapse

Methods inherited from Gollum::Filter

#initialize

Methods included from Helpers

#trim_leading_slash

Constructor Details

This class inherits a constructor from Gollum::Filter

Instance Method Details

#extract(data) ⇒ Object

Extract all sequence diagram blocks into the map and replace with placeholders.



16
17
18
19
20
21
22
23
# File 'lib/gollum-lib/filter/wsd.rb', line 16

def extract(data)
  return data if @markup.format == :txt
  data.gsub(/^\{\{\{\{\{\{ ?(.+?)\r?\n(.+?)\r?\n\}\}\}\}\}\}\r?$/m) do
    id       = Digest::SHA1.hexdigest(Regexp.last_match[2])
    @map[id] = { :style => Regexp.last_match[1], :code => Regexp.last_match[2] }
    id
  end
end

#process(data) ⇒ Object

Process all diagrams from the map and replace the placeholders with the final HTML.

data - The String data (with placeholders).

Returns the marked up String data.



31
32
33
34
35
36
37
38
# File 'lib/gollum-lib/filter/wsd.rb', line 31

def process(data)
  @map.each do |id, spec|
    data.gsub!(id) do
      render_wsd(spec[:code], spec[:style])
    end
  end
  data
end