Module: SimpleMarkdown::ActionView::Helpers

Defined in:
lib/simple_markdown/action_view/helpers.rb

Constant Summary collapse

USELESS_LINE =
/^$/
CODE_BLOCK =
/^\s*```\s*$/
CODE_INLINE =
/`([^`]+)`/
TITLE =
/^\s*\#/
FLEX_HEAD =
/^\s*\[[0-9]+-?flex-?[0-9]*\]\s*$/
FLEX =
/^\s*\[flex-?[0-9]*\]\s*$/
CENTER_BLOCK_1 =
/^\s*->\s*$/
CENTER_BLOCK_2 =
/^\s*<-\s*/
CENTER_INLINE =
/^\s*->(.*)<-(\s*)$/
/(^|[^!])\[([^\]]*)\]\(([^\)]*)\)/
IMAGE =
/!\[([^\]]*)\]\(([^\)]*)\)/
LIST =
/^\s*\*\s(.*)/
ITALIC =
/(^|[^\*])\*([^\*]+)\*/
BOLD =
/\*\*([^\*]*)\*\*/
RETURN =
/\s{2,}$/

Instance Method Summary collapse

Instance Method Details

#simple_markdown(text) ⇒ Object

Main entry



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/simple_markdown/action_view/helpers.rb', line 28

def simple_markdown(text)
  text = text.gsub(/\r\n?/, "\n").split(/\n/)
  @text_map = text.map
  @io = StringIO.new
  begin
    while(true)
      parse_block
    end
  rescue StopIteration
  ensure
    return @io.string.html_safe
  end
end