Module: Coradoc::Parser::Asciidoc::Text

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

Instance Method Summary collapse

Instance Method Details

#attr_nameObject



95
96
97
# File 'lib/coradoc/parser/asciidoc/text.rb', line 95

def attr_name
  match("[^\t\s]").repeat(1)
end

#block_imageObject



119
120
121
122
123
124
125
126
127
128
# File 'lib/coradoc/parser/asciidoc/text.rb', line 119

def block_image
  (block_id.maybe >>
    block_title.maybe >>
    (attribute_list >> newline).maybe >>
    match('^i') >> str("mage::") >>
    file_path.as(:path) >>
    attribute_list(:attribute_list_macro) >>
    newline.as(:line_break)
    ).as(:block_image)
end

#comment_blockObject



149
150
151
152
153
154
155
# File 'lib/coradoc/parser/asciidoc/text.rb', line 149

def comment_block
  ( str('////') >> line_ending >>
  ((line_ending >> str('////')).absent? >> any
    ).repeat.as(:comment_text) >> 
  line_ending >> str('////')
  ).as(:comment_block)
end

#comment_lineObject



130
131
132
133
134
135
136
# File 'lib/coradoc/parser/asciidoc/text.rb', line 130

def comment_line
  tag.absent? >>
  (str('//') >> str("/").absent? >>
    space? >>
    text.as(:comment_text)
    ).as(:comment_line)
end

#dateObject



90
91
92
93
# File 'lib/coradoc/parser/asciidoc/text.rb', line 90

def date
  digit.repeat(2, 4) >> str("-") >>
    digit.repeat(1, 2) >> str("-") >> digit.repeat(1, 2)
end

#digitObject



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

def digit
  match("[0-9]")
end

#digitsObject



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

def digits
  match("[0-9]").repeat(1)
end

#emailObject



82
83
84
# File 'lib/coradoc/parser/asciidoc/text.rb', line 82

def email
  word >> str("@") >> word >> str(".") >> word
end

#empty_lineObject



54
55
56
# File 'lib/coradoc/parser/asciidoc/text.rb', line 54

def empty_line
  match("^\n")
end

#endlineObject



34
35
36
# File 'lib/coradoc/parser/asciidoc/text.rb', line 34

def endline
  newline | any.absent?
end

#eof?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/coradoc/parser/asciidoc/text.rb', line 26

def eof?
  any.absent?
end

#file_pathObject



99
100
101
# File 'lib/coradoc/parser/asciidoc/text.rb', line 99

def file_path
  match('[^\[]').repeat(1)
end

#include_directiveObject



103
104
105
106
107
108
109
# File 'lib/coradoc/parser/asciidoc/text.rb', line 103

def include_directive
  (str("include::") >> 
    file_path.as(:path) >>
    attribute_list >>
  (newline | str("")).as(:line_break)
  ).as(:include)
end

#inline_imageObject



111
112
113
114
115
116
117
# File 'lib/coradoc/parser/asciidoc/text.rb', line 111

def inline_image
  (str("image::") >> 
    file_path.as(:path) >>
    attribute_list >>
  (line_ending)
  ).as(:inline_image)
end

#keywordObject



50
51
52
# File 'lib/coradoc/parser/asciidoc/text.rb', line 50

def keyword
  (match('[a-zA-Z0-9_\-.,]') | str(".")).repeat(1)
end

#line_endObject



30
31
32
# File 'lib/coradoc/parser/asciidoc/text.rb', line 30

def line_end
  str("\n") | str("\r\n") | eof?
end

#line_endingObject



22
23
24
# File 'lib/coradoc/parser/asciidoc/text.rb', line 22

def line_ending
  str("\n") #| match('[\z]')# | match('$')
end

#line_start?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/coradoc/parser/asciidoc/text.rb', line 18

def line_start?
  match('^[^\n]').present?
end

#newlineObject

def endline_single

newline_single | any.absent?

end



42
43
44
# File 'lib/coradoc/parser/asciidoc/text.rb', line 42

def newline
  (str("\n") | str("\r\n")).repeat(1)
end

#newline_singleObject



46
47
48
# File 'lib/coradoc/parser/asciidoc/text.rb', line 46

def newline_single
  (str("\n") | str("\r\n"))
end

#rich_textObject



78
79
80
# File 'lib/coradoc/parser/asciidoc/text.rb', line 78

def rich_text
  (match("[a-zA-Z0-9_-]") | str(".") | str("*") | match("@")).repeat(1)
end

#rich_textsObject



74
75
76
# File 'lib/coradoc/parser/asciidoc/text.rb', line 74

def rich_texts
  rich_text >> (space? >> rich_text).repeat
end

#spaceObject



10
11
12
# File 'lib/coradoc/parser/asciidoc/text.rb', line 10

def space
  str(' ').repeat(1)
end

#space?Boolean

Returns:

  • (Boolean)


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

def space?
  space.maybe
end

#special_characterObject



86
87
88
# File 'lib/coradoc/parser/asciidoc/text.rb', line 86

def special_character
  match("^[*:=-]") | str("[#") | str("[[")
end

#tagObject



138
139
140
141
142
143
144
145
146
147
# File 'lib/coradoc/parser/asciidoc/text.rb', line 138

def tag
  (str('//') >> str('/').absent? >>
    space? >>
    (str('tag') | str('end')).as(:prefix) >>
    str('::') >> str(':').absent? >>
    match('[^\[]').repeat(1).as(:name) >>
    attribute_list >>
    line_ending.maybe.as(:line_break)
    ).as(:tag)
end

#textObject



14
15
16
# File 'lib/coradoc/parser/asciidoc/text.rb', line 14

def text
  match("[^\n]").repeat(1)
end

#wordObject



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

def word
  match("[a-zA-Z0-9_-]").repeat(1)
end

#wordsObject



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

def words
  word >> (space? >> word).repeat
end