module WikiThat::Rule

Lexer module for horizontal rules @author Bryan T. Meyers

Lexer module for horizontal rules @author Bryan T. Meyers

Public Instance Methods

lex_horizontal_rule() click to toggle source

Lex the current text as a horizontal rule if found

# File lib/wiki-that/lexer/tokens/rule.rb, line 29
def lex_horizontal_rule
  count = 0
  while match? RULE_SPECIAL
    count += 1
    advance
  end
  if count == 1
    append Token.new(:text, '-')
  else
    append Token.new(:rule, count)
  end

end
parse_rule(inline = false) click to toggle source

Parse the current text as a horizontal rule if found

# File lib/wiki-that/parser/elements/rule.rb, line 25
def parse_rule(inline = false)
  case current.value
    when 1
      e = Element.new(:text,'-')
    when 2
      e = Element.new(:text,'—')
    else
      if inline
        e =  Element.new(:text, '-' * current.value)
      else
        e = Element.new(:hr)
      end
  end
  advance
  e
end