Module: Coradoc::Parser::Asciidoc::List
- Included in:
- Base
- Defined in:
- lib/coradoc/parser/asciidoc/list.rb
Instance Method Summary collapse
- #definition_list(delimiter = "::") ⇒ Object
- #dlist_definition ⇒ Object
- #dlist_delimiter ⇒ Object
- #dlist_item(delimiter) ⇒ Object
- #dlist_term(delimiter) ⇒ Object
- #list(nesting_level = 1) ⇒ Object
- #list_continuation ⇒ Object
- #list_marker(nesting_level = 1) ⇒ Object
- #olist_item(nesting_level = 1) ⇒ Object
- #olist_marker(nesting_level = 1) ⇒ Object
- #ordered_list(nesting_level = 1) ⇒ Object
- #ulist_item(nesting_level = 1) ⇒ Object
- #ulist_marker(nesting_level = 1) ⇒ Object
- #unordered_list(nesting_level = 1) ⇒ Object
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_definition ⇒ Object
100 101 102 103 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 100 def dlist_definition (text #>> empty_line.repeat(0) ).as(:definition) >> line_ending >> empty_line.repeat(0) end |
#dlist_delimiter ⇒ Object
90 91 92 93 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 90 def dlist_delimiter (str("::") | str(":::") | str("::::") | str(";;") ).as(:delimiter) end |
#dlist_item(delimiter) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 105 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
95 96 97 98 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 95 def dlist_term(delimiter) (match("[^\n:]").repeat(1) #>> empty_line.repeat(0) ).as(:term) >> dlist_delimiter end |
#list(nesting_level = 1) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 7 def list(nesting_level = 1) ( unordered_list(nesting_level) | ordered_list(nesting_level) | definition_list ).as(:list) end |
#list_continuation ⇒ Object
15 16 17 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 15 def list_continuation line_start? >> str("+\n") end |
#list_marker(nesting_level = 1) ⇒ Object
37 38 39 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 37 def list_marker(nesting_level = 1) olist_marker(nesting_level) | ulist_marker(nesting_level) end |
#olist_item(nesting_level = 1) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 45 def olist_item(nesting_level = 1) item = olist_marker(nesting_level).as(:marker) >> match("\n").absent? >> space >> text_line(true)# >> # (list_continuation.present? >> list_continuation >> # paragraph #| example_block(n_deep: 1) # ).repeat(0).as(:attached) att = (list_continuation.present? >> list_continuation >> (admonition_line | paragraph | block) #(n_deep: 1)) ).repeat(0).as(:attached) item = item >> att.maybe if nesting_level <= 4 item = item >> (list_marker(nesting_level + 1).present? >> list(nesting_level + 1)).repeat(0).as(:nested)#).maybe end olist_marker(nesting_level).present? >> item.as(:list_item) end |
#olist_marker(nesting_level = 1) ⇒ Object
41 42 43 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 41 def olist_marker(nesting_level = 1) line_start? >> str('.' * nesting_level) >> str('.').absent? end |
#ordered_list(nesting_level = 1) ⇒ Object
19 20 21 22 23 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 19 def ordered_list(nesting_level = 1) attrs = (attribute_list >> newline).maybe r = olist_item(nesting_level) attrs >> olist_item(nesting_level).present? >> r.repeat(1).as(:ordered) end |
#ulist_item(nesting_level = 1) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 71 def ulist_item(nesting_level = 1) item = ulist_marker(nesting_level).as(:marker) >> str(' [[[').absent? >> match("\n").absent? >> space >> text_line(true) att = (list_continuation.present? >> list_continuation >> (admonition_line | paragraph | block) #(n_deep: 1)) ).repeat(0).as(:attached) item = item >> att.maybe if nesting_level <= 4 item = item >> (list_marker(nesting_level + 1).present? >> list(nesting_level + 1)).repeat(0).as(:nested)#).maybe end ulist_marker(nesting_level).present? >> item.as(:list_item) end |
#ulist_marker(nesting_level = 1) ⇒ Object
67 68 69 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 67 def ulist_marker(nesting_level = 1) line_start? >> str('*' * nesting_level) >> str('*').absent? end |
#unordered_list(nesting_level = 1) ⇒ Object
25 26 27 28 29 |
# File 'lib/coradoc/parser/asciidoc/list.rb', line 25 def unordered_list(nesting_level = 1) attrs = (attribute_list >> newline).maybe r = ulist_item(nesting_level) attrs >> r.repeat(1).as(:unordered) end |