Module: OMF::Web::Widget::Text::Maruku

Defined in:
lib/omf-web/widget/text/maruku.rb

Defined Under Namespace

Classes: WidgetElement

Constant Summary collapse

OpenMatch =
/^\s*\{\{\{\s*(.*)$/
CloseMatch =
/(.*)\}\}\}/

Class Method Summary collapse

Class Method Details

.count_header_lines(content) ⇒ Object

The markdown document may have some meta instructions at the beginning of the document which are formatted like an HTTP header



48
49
50
51
52
53
54
55
# File 'lib/omf-web/widget/text/maruku.rb', line 48

def self.count_header_lines(content)
  count = 0
  match = (content =~ /\A((\w[\w\s\_\-]+: .*\n)+)\s*\n/)
  return 0 if match != 0

  headers = $1
  headers.split("\n").length + 1
end

.format_content(content) ⇒ Object



42
43
44
# File 'lib/omf-web/widget/text/maruku.rb', line 42

def self.format_content(content)
  ::Maruku.new(content)
end

.format_content_proxy(content_proxy) ⇒ Object

Fetch text and parse it



35
36
37
38
39
40
# File 'lib/omf-web/widget/text/maruku.rb', line 35

def self.format_content_proxy(content_proxy)
  unless content_proxy.is_a? OMF::Web::ContentProxy
    raise "Expected content proxy, but got '#{content_proxy.class}'"
  end
  format_content(content_proxy.content)
end