Module: Coradoc::Parser::Asciidoc::Content

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

Instance Method Summary collapse

Instance Method Details

#asciidoc_charObject



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

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

#asciidoc_char_with_idObject



53
54
55
# File 'lib/coradoc/parser/asciidoc/content.rb', line 53

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

#glossariesObject



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

def glossaries
  glossary.repeat(1)
end

#glossaryObject



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

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

#highlightObject



6
7
8
9
# File 'lib/coradoc/parser/asciidoc/content.rb', line 6

def highlight
  text_id >> newline >>
    underline >> highlight_text >> newline
end

#highlight_textObject



15
16
17
# File 'lib/coradoc/parser/asciidoc/content.rb', line 15

def highlight_text
  str("#") >> words.as(:text) >> str("#")
end

#list_prefixObject



28
29
30
# File 'lib/coradoc/parser/asciidoc/content.rb', line 28

def list_prefix
  (line_start? >> match('^[*\.]') >> str(' '))
end

#literal_spaceObject



19
20
21
# File 'lib/coradoc/parser/asciidoc/content.rb', line 19

def literal_space
  (match[" "] | match[' \t']).repeat(1)
end

#literal_space?Boolean

Override

Returns:

  • (Boolean)


24
25
26
# File 'lib/coradoc/parser/asciidoc/content.rb', line 24

def literal_space?
  literal_space.maybe
end

#section_prefixObject



32
33
34
# File 'lib/coradoc/parser/asciidoc/content.rb', line 32

def section_prefix
  (line_start? >> match('^[=]') >> str('=').repeat(0) >> match('[^\n]'))
end

#text_idObject



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

def text_id
  str("[[") >> str('[').absent? >> keyword.as(:id) >> str("]]") |
    str("[#") >> keyword.as(:id) >> str("]")
end

#text_line(many_breaks = false) ⇒ Object

Text



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/coradoc/parser/asciidoc/content.rb', line 37

def text_line(many_breaks = false)  #:zero :one :many
    tl = #section_prefix.absent? >>
         # list_prefix.absent? >>
    (asciidoc_char_with_id.absent? | text_id) >> literal_space? >>
    text.as(:text)
    if many_breaks
      tl >> line_ending.repeat(1).as(:line_break)
    else
      tl >> line_ending.as(:line_break)
    end
end

#underlineObject



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

def underline
  str("[underline]") | str("[.underline]")
end