Module: Coradoc::Parser::Asciidoc::Paragraph
- Included in:
- Base
- Defined in:
- lib/coradoc/parser/asciidoc/paragraph.rb
Instance Method Summary collapse
- #line_not_text? ⇒ Boolean
- #paragraph ⇒ Object
- #paragraph_attributes ⇒ Object
-
#paragraph_text_line(many_breaks = false) ⇒ Object
TODO: This is crazy that many_breaks can be 0, true or false!?.
Instance Method Details
#line_not_text? ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/coradoc/parser/asciidoc/paragraph.rb', line 5 def line_not_text? line_start? >> (attribute_list >> newline).absent? >> block_delimiter.absent? >> list.absent? >> list_prefix.absent? >> list_continuation.absent? >> element_id.absent? >> section_prefix.absent? end |
#paragraph ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/coradoc/parser/asciidoc/paragraph.rb', line 32 def paragraph (element_id.maybe >> block_title.maybe >> (attribute_list >> newline).maybe >> ((paragraph_text_line(0).repeat(1, 1) >> (newline.repeat(1).as(:line_break) | eof?)) | paragraph_text_line(false).repeat(1) >> (paragraph_text_line(true).repeat(1, 1) >> (newline.repeat(1).as(:line_break) | eof?)).repeat(0, 1) ).as(:lines) >> (newline.repeat(0) | eof?) ).as(:paragraph) end |
#paragraph_attributes ⇒ Object
46 47 48 49 50 |
# File 'lib/coradoc/parser/asciidoc/paragraph.rb', line 46 def paragraph_attributes str("[") >> keyword.as(:key) >> str("=") >> word.as(:value) >> str("]") >> newline end |
#paragraph_text_line(many_breaks = false) ⇒ Object
TODO: This is crazy that many_breaks can be 0, true or false!?
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/coradoc/parser/asciidoc/paragraph.rb', line 17 def paragraph_text_line(many_breaks = false) tl = line_not_text? >> (asciidoc_char_with_id.absent? | element_id_inline >> literal_space? | line_start? >> line_not_text?) >> text_any.as(:text) if many_breaks == 0 tl >> eof? elsif many_breaks tl >> (newline.as(:line_break) | eof?) else tl >> (newline_single.as(:line_break) | eof?) end end |