Module: Coradoc::AsciiDoc::Parser::Content

Included in:
Base
Defined in:
lib/coradoc/asciidoc/parser/content.rb

Instance Method Summary collapse

Instance Method Details

#asciidoc_charObject



41
42
43
# File 'lib/coradoc/asciidoc/parser/content.rb', line 41

def asciidoc_char
  line_start? >> match['*_:+=\-']
end

#asciidoc_char_with_idObject



45
46
47
# File 'lib/coradoc/asciidoc/parser/content.rb', line 45

def asciidoc_char_with_id
  asciidoc_char | str('[#') | str('[[')
end

#element_idObject



49
50
51
52
53
54
# File 'lib/coradoc/asciidoc/parser/content.rb', line 49

def element_id
  line_start? >>
    ((str('[[') >> keyword.as(:id) >> str(']]')) |
       (str('[#') >> keyword.as(:id) >> str(']'))
    ) >> newline
end

#element_id_inlineObject



56
57
58
59
# File 'lib/coradoc/asciidoc/parser/content.rb', line 56

def element_id_inline
  (str('[[') >> keyword.as(:id) >> str(']]')) |
    (str('[#') >> keyword.as(:id) >> str(']'))
end

#glossariesObject



66
67
68
# File 'lib/coradoc/asciidoc/parser/content.rb', line 66

def glossaries
  glossary.repeat(1)
end

#glossaryObject



61
62
63
64
# File 'lib/coradoc/asciidoc/parser/content.rb', line 61

def glossary
  keyword.as(:key) >> str('::') >> (str(' ') | newline) >>
    text.as(:value) >> line_ending.as(:line_break)
end

#list_prefixObject



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_spaceObject



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

Returns:

  • (Boolean)


12
13
14
# File 'lib/coradoc/asciidoc/parser/content.rb', line 12

def literal_space?
  literal_space.maybe
end

#page_breakObject



70
71
72
# File 'lib/coradoc/asciidoc/parser/content.rb', line 70

def page_break
  str('<<<') >> line_ending
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
         text_any.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