Module: Coradoc::AsciiDoc::Parser::Content
- Included in:
- Base
- Defined in:
- lib/coradoc/asciidoc/parser/content.rb
Instance Method Summary collapse
- #asciidoc_char ⇒ Object
- #asciidoc_char_with_id ⇒ Object
- #element_id ⇒ Object
- #element_id_inline ⇒ Object
- #glossaries ⇒ Object
- #glossary ⇒ Object
- #list_prefix ⇒ Object
- #literal_space ⇒ Object
-
#literal_space? ⇒ Boolean
Override.
- #page_break ⇒ Object
-
#raw_verbatim_line ⇒ Object
A verbatim source/listing line: capture every character up to the next newline without applying any inline substitutions.
-
#text_line(many_breaks = false, unguarded: false, verbatim: false) ⇒ Object
Text :zero :one :many.
Instance Method Details
#asciidoc_char ⇒ Object
50 51 52 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 50 def asciidoc_char line_start? >> match['*_:+=\-'] end |
#asciidoc_char_with_id ⇒ Object
54 55 56 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 54 def asciidoc_char_with_id asciidoc_char | str('[#') | str('[[') end |
#element_id ⇒ Object
58 59 60 61 62 63 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 58 def element_id line_start? >> ((str('[[') >> keyword.as(:id) >> str(']]')) | (str('[#') >> keyword.as(:id) >> str(']')) ) >> newline end |
#element_id_inline ⇒ Object
65 66 67 68 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 65 def element_id_inline (str('[[') >> keyword.as(:id) >> str(']]')) | (str('[#') >> keyword.as(:id) >> str(']')) end |
#glossaries ⇒ Object
75 76 77 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 75 def glossaries glossary.repeat(1) end |
#glossary ⇒ Object
70 71 72 73 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 70 def glossary keyword.as(:key) >> str('::') >> (str(' ') | newline) >> text.as(:value) >> line_ending.as(:line_break) end |
#list_prefix ⇒ Object
16 17 18 19 20 21 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 16 def list_prefix (line_start? >> ((match('^[*]') >> str('*').repeat(1, 5)) | (match('^[\.]') >> str('.').repeat(1, 5))) >> str(' ')) end |
#literal_space ⇒ Object
7 8 9 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 7 def literal_space (match[' '] | match[' \t']).repeat(1) end |
#literal_space? ⇒ Boolean
Override
12 13 14 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 12 def literal_space? literal_space.maybe end |
#page_break ⇒ Object
79 80 81 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 79 def page_break str('<<<') >> line_ending end |
#raw_verbatim_line ⇒ Object
A verbatim source/listing line: capture every character up to the next newline without applying any inline substitutions. Source and listing blocks must round-trip their text untouched — otherwise sequences like Liquid ‘var }` collide with AsciiDoc attribute references and get rewritten.
46 47 48 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 46 def raw_verbatim_line (line_ending.absent? >> any).repeat(1) end |
#text_line(many_breaks = false, unguarded: false, verbatim: false) ⇒ Object
Text :zero :one :many
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/coradoc/asciidoc/parser/content.rb', line 25 def text_line(many_breaks = false, unguarded: false, verbatim: false) tl = if verbatim raw_verbatim_line.as(:text) elsif unguarded literal_space? >> text_any.as(:text) else (asciidoc_char_with_id.absent? | element_id_inline) >> literal_space? >> text_any.as(:text) end if many_breaks tl >> (line_ending.repeat(1).as(:line_break) | eof?) else tl >> (line_ending.as(:line_break) | eof?) end end |