Module: Tight::Engine::Render

Defined in:
lib/tight-engine/render.rb

Constant Summary collapse

MAX_PARSE_LEVEL =
4
REGEX_RECURSIVE_BRACKETS =
/
  (?<re>             #
    \[               #
    (?:              #
      (?>[^\[\]]+)   # 1
      |              #
      \g<re>         #
    )*               #
    \]               #
  )                  #
/x.freeze

Instance Method Summary collapse

Instance Method Details

#engine_render(text) ⇒ Object



22
23
24
# File 'lib/tight-engine/render.rb', line 22

def engine_render( text )
  Markdown.render( parse_content( text.to_s ) ).html_safe
end

#inline_render(text) ⇒ Object



26
27
28
# File 'lib/tight-engine/render.rb', line 26

def inline_render( text )
  engine_render( text ).gsub(/^<p>(.*)<\/p>$/, '\1').chomp
end

#strip_code(text) ⇒ Object



18
19
20
# File 'lib/tight-engine/render.rb', line 18

def strip_code( text )
  text && text.gsub(REGEX_RECURSIVE_BRACKETS, '').strip
end