Module: Coradoc::Parser::Asciidoc::Section

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

Instance Method Summary collapse

Instance Method Details

#contentsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/coradoc/parser/asciidoc/section.rb', line 6

def contents
  (
    citation |
    term | term2 |
    bib_entry |
    block_image |
    tag |
    comment_block |
    comment_line |
    include_directive |
    admonition_line |
    block.as(:block) |
    table.as(:table) |
    highlight.as(:highlight) |
    glossaries.as(:glossaries) |
    paragraph |
    list |
    empty_line.as(:line_break)
  ).repeat(1)
end

#section(level = 2) ⇒ Object

section



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/coradoc/parser/asciidoc/section.rb', line 50

def section(level = 2)
  r = section_block(level) 
  if level < 8
    r = r >> section(level + 1).as(:section).repeat(0).as(:sections)
  end
  if level == 2
    (r).as(:section)
  else
    r
  end
end

#section_block(level = 2) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/coradoc/parser/asciidoc/section.rb', line 27

def section_block(level = 2)
  return nil if level > 8
  (attribute_list >> newline).maybe >>
  section_id.maybe >>
  (attribute_list >> newline).maybe >>
    section_title(level).as(:title) >>
    contents.as(:contents).maybe
end

#section_idObject

Section id



37
38
39
40
# File 'lib/coradoc/parser/asciidoc/section.rb', line 37

def section_id
  (str("[[") >> keyword.as(:id) >> str("]]") |
    str("[#") >> keyword.as(:id) >> str("]")) >> newline
end

#section_title(level = 2, max_level = 8) ⇒ Object

Heading



43
44
45
46
47
# File 'lib/coradoc/parser/asciidoc/section.rb', line 43

def section_title(level = 2, max_level = 8)
  match("=").repeat(level, max_level).as(:level) >>
    str('=').absent? >>
    space? >> text.as(:text) >> endline.as(:line_break)
end