Module: Coradoc::AsciiDoc::Parser::List
- Defined in:
- lib/coradoc/asciidoc/parser/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
32 33 34 35 36 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 32 def definition_list(delimiter = '::') (attribute_list >> newline).maybe >> dlist_item(delimiter).repeat(1).as(:definition_list) >> dlist_item(delimiter).absent? end |
#dlist_definition ⇒ Object
112 113 114 115 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 112 def dlist_definition text # >> empty_line.repeat(0) .as(:definition) >> line_ending >> empty_line.repeat(0) end |
#dlist_delimiter ⇒ Object
100 101 102 103 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 100 def dlist_delimiter (str('::') | str(':::') | str('::::') | str(';;') ).as(:delimiter) end |
#dlist_item(delimiter) ⇒ Object
117 118 119 120 121 122 123 124 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 117 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) end |
#dlist_term(_delimiter) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 105 def dlist_term(_delimiter) (element_id_inline.maybe >> match("[^\n:]").repeat(1) .as(:text) ).as(:dlist_term) >> dlist_delimiter end |
#list(nesting_level = 1) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 8 def list(nesting_level = 1) ( unordered_list(nesting_level) | ordered_list(nesting_level) | definition_list ).as(:list) end |
#list_continuation ⇒ Object
16 17 18 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 16 def list_continuation line_start? >> str("+\n") end |
#list_marker(nesting_level = 1) ⇒ Object
38 39 40 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 38 def list_marker(nesting_level = 1) olist_marker(nesting_level) | ulist_marker(nesting_level) end |
#olist_item(nesting_level = 1) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 53 def olist_item(nesting_level = 1) item = olist_marker(nesting_level).as(:marker) >> match("\n").absent? >> space >> text_line(true, unguarded: 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 >>= att.maybe if nesting_level <= 4 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
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 42 def olist_marker(nesting_level = 1) # Don't match table cell format specs like ".2+^.^|" line_start? >> (nesting_level > 1 ? literal_space.maybe : str('')) >> str('.' * nesting_level) >> str('.').absent? >> ( (match['0-9.<>^'] | str('+')).repeat(0, 3) >> str('|') ).absent? end |
#ordered_list(nesting_level = 1) ⇒ Object
20 21 22 23 24 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 20 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
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 82 def ulist_item(nesting_level = 1) item = ulist_marker(nesting_level).as(:marker) >> str(' [[[').absent? >> match("\n").absent? >> space >> text_line(true, unguarded: true) att = (list_continuation.present? >> list_continuation >> (admonition_line | paragraph | block) # (n_deep: 1)) ).repeat(0).as(:attached) item >>= att.maybe if nesting_level <= 4 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
74 75 76 77 78 79 80 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 74 def ulist_marker(nesting_level = 1) line_start? >> (nesting_level > 1 ? literal_space.maybe : str('')) >> str('*' * nesting_level) >> str('*').absent? >> str('===').absent? end |
#unordered_list(nesting_level = 1) ⇒ Object
26 27 28 29 30 |
# File 'lib/coradoc/asciidoc/parser/list.rb', line 26 def unordered_list(nesting_level = 1) attrs = (attribute_list >> newline).maybe r = ulist_item(nesting_level) attrs >> r.repeat(1).as(:unordered) end |