Module: Coradoc::Parser::Asciidoc::Content

Included in:
Base, Base
Defined in:
lib/coradoc/parser/asciidoc/content.rb

Instance Method Summary collapse

Instance Method Details

#asciidoc_charObject



39
40
41
# File 'lib/coradoc/parser/asciidoc/content.rb', line 39

def asciidoc_char
  match('^[*_:=\-+]')
end

#asciidoc_char_with_idObject



43
44
45
# File 'lib/coradoc/parser/asciidoc/content.rb', line 43

def asciidoc_char_with_id
  asciidoc_char | str('[#') | str('[[')
end

#glossariesObject



57
58
59
# File 'lib/coradoc/parser/asciidoc/content.rb', line 57

def glossaries
  glossary.repeat(1)
end

#glossaryObject



52
53
54
55
# File 'lib/coradoc/parser/asciidoc/content.rb', line 52

def glossary
  keyword.as(:key) >> str("::") >> (str(" ") | newline) >>
    text.as(:value) >> line_ending.as(:line_break)
end

#highlightObject



6
7
8
9
# File 'lib/coradoc/parser/asciidoc/content.rb', line 6

def highlight
  text_id >> newline >>
    underline >> highlight_text >> newline
end

#highlight_textObject



15
16
17
# File 'lib/coradoc/parser/asciidoc/content.rb', line 15

def highlight_text
  str("#") >> words.as(:text) >> str("#")
end

#literal_spaceObject



19
20
21
# File 'lib/coradoc/parser/asciidoc/content.rb', line 19

def literal_space
  (match[" "] | match[' \t']).repeat(1)
end

#literal_space?Boolean

Override

Returns:

  • (Boolean)


24
25
26
# File 'lib/coradoc/parser/asciidoc/content.rb', line 24

def literal_space?
  literal_space.maybe
end

#text_idObject



47
48
49
50
# File 'lib/coradoc/parser/asciidoc/content.rb', line 47

def text_id
  str("[[") >> str('[').absent? >> keyword.as(:id) >> str("]]") |
    str("[#") >> keyword.as(:id) >> str("]")
end

#text_line(many_breaks = false) ⇒ Object

Text



29
30
31
32
33
34
35
36
37
# File 'lib/coradoc/parser/asciidoc/content.rb', line 29

def text_line(many_breaks = false)
    tl = (asciidoc_char_with_id.absent? | text_id) >> literal_space? >>
    text.as(:text)
    if many_breaks
      tl >> line_ending.repeat(1).as(:line_break)
    else
      tl >> line_ending.as(:line_break)
    end
end

#underlineObject



11
12
13
# File 'lib/coradoc/parser/asciidoc/content.rb', line 11

def underline
  str("[underline]") | str("[.underline]")
end