Module: Coradoc::Parser::Asciidoc::List

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

Instance Method Summary collapse

Instance Method Details

#definition_list(delimiter = "::") ⇒ Object



31
32
33
34
35
# File 'lib/coradoc/parser/asciidoc/list.rb', line 31

def definition_list(delimiter = "::")
  (attribute_list >> newline).maybe >>
  dlist_item(delimiter).as(:definition_list).repeat(1) >>
  dlist_item(delimiter).absent?
end

#dlist_definitionObject



66
67
68
69
# File 'lib/coradoc/parser/asciidoc/list.rb', line 66

def dlist_definition
  (text #>> empty_line.repeat(0)
    ).as(:definition) >> line_ending >> empty_line.repeat(0)
end

#dlist_delimiterObject



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

def dlist_delimiter
  (str("::") | str(":::") | str("::::") | str(";;")
    ).as(:delimiter)
end

#dlist_item(delimiter) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/coradoc/parser/asciidoc/list.rb', line 71

def dlist_item(delimiter)
  (((dlist_term(delimiter).as(:terms).repeat(1) >> line_ending >>
    empty_line.repeat(0)).repeat(1) >>
    dlist_definition)  |
    (dlist_term(delimiter).repeat(1,1).as(:terms) >> space >> dlist_definition)
    ).as(:definition_list_item).repeat(1)
end

#dlist_term(delimiter) ⇒ Object



61
62
63
64
# File 'lib/coradoc/parser/asciidoc/list.rb', line 61

def dlist_term(delimiter)
  (match("[^\n:]").repeat(1) #>> empty_line.repeat(0)
    ).as(:term) >> dlist_delimiter
end

#listObject



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

def list
  (
  unordered_list |
     ordered_list # definition_list |
    ).as(:list)
end

#olist_item(nesting_level = 1) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/coradoc/parser/asciidoc/list.rb', line 37

def olist_item(nesting_level = 1)
  nl2 = nesting_level - 1
  marker = match(/^\./)
  marker = marker >>  str(".").repeat(nl2, nl2) if nl2 > 0
  str("").as(:list_item) >> 
  marker.as(:marker) >> str(".").absent? >>
  match("\n").absent? >> space >> text_line(true)
end

#ordered_list(nesting_level = 1) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/coradoc/parser/asciidoc/list.rb', line 13

def ordered_list(nesting_level = 1)
  attrs = (attribute_list >> newline).maybe
  r = olist_item(nesting_level)
  if nesting_level <= 8
    r = r | ordered_list(nesting_level + 1)
  end
  attrs >> r.repeat(1).as(:ordered)
end

#ulist_item(nesting_level = 1) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/coradoc/parser/asciidoc/list.rb', line 46

def ulist_item(nesting_level = 1)
  nl2 = nesting_level - 1
  marker = match(/^\*/)
  marker = marker >>  str("*").repeat(nl2, nl2) if nl2 > 0
  str("").as(:list_item) >>
  marker.as(:marker) >> str("*").absent? >>
  str(' [[[').absent? >>
  match("\n").absent? >> space >> text_line(true)
end

#unordered_list(nesting_level = 1) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/coradoc/parser/asciidoc/list.rb', line 22

def unordered_list(nesting_level = 1)
  attrs = (attribute_list >> newline).maybe
  r = ulist_item(nesting_level)
  if nesting_level <= 8
    r = r | unordered_list(nesting_level + 1)
  end
  attrs >> r.repeat(1).as(:unordered)
end