Module: Coradoc::AsciiDoc::Parser::Section
- Defined in:
- lib/coradoc/asciidoc/parser/section.rb
Instance Method Summary collapse
- #contents ⇒ Object
-
#section(level = 2) ⇒ Object
section.
- #section_block(level = 2) ⇒ Object
- #section_prefix ⇒ Object
-
#section_title(level = 2, max_level = 8) ⇒ Object
Heading.
Instance Method Details
#contents ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/coradoc/asciidoc/parser/section.rb', line 7 def contents ( bib_entry | block_image | tag | comment_block | comment_line | include_directive | admonition_line | block | table.as(:table) | page_break.as(:page_break) | # 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 |
# File 'lib/coradoc/asciidoc/parser/section.rb', line 50 def section(level = 2) r = section_block(level) r >>= section(level + 1).as(:section).repeat(0).as(:sections) if level < 8 if level == 2 r.as(:section) else r end end |
#section_block(level = 2) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/coradoc/asciidoc/parser/section.rb', line 27 def section_block(level = 2) return nil if level > 8 (attribute_list >> newline).maybe >> element_id.maybe >> (attribute_list >> newline).maybe >> section_title(level).as(:title) >> contents.as(:contents).maybe end |
#section_prefix ⇒ Object
37 38 39 |
# File 'lib/coradoc/asciidoc/parser/section.rb', line 37 def section_prefix (line_start? >> match('^[=]') >> str('=').repeat(0) >> match('[^\n]')) end |
#section_title(level = 2, max_level = 8) ⇒ Object
Heading
42 43 44 45 46 47 |
# File 'lib/coradoc/asciidoc/parser/section.rb', line 42 def section_title(level = 2, max_level = 8) line_start? >> match('=').repeat(level, max_level).as(:level) >> str('=').absent? >> space? >> text.as(:text) >> endline.as(:line_break) end |