Module: Coradoc::AsciiDoc::Parser::Text

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

Instance Method Summary collapse

Instance Method Details

#attr_nameObject



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

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

#block_imageObject

block_image is defined in inline.rb with full syntax inline_image is defined in inline.rb for inline images (image:)



115
116
117
118
119
120
121
122
# File 'lib/coradoc/asciidoc/parser/text.rb', line 115

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

#comment_blockObject



164
165
166
167
168
169
170
# File 'lib/coradoc/asciidoc/parser/text.rb', line 164

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

#comment_lineObject



144
145
146
147
148
149
150
151
# File 'lib/coradoc/asciidoc/parser/text.rb', line 144

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

#comment_line_contentObject

Non-capturing form of #comment_line. Same shape (a // comment line, excluding tag directives like // tag::), but consumes without producing an AST node.

Used by list rules to absorb inter-item comments so the list continues across them — asciidoctor treats // comments inside any list as structurally invisible. Uses raw character matchers instead of text so no inner captures leak into the consuming rule's AST.

Single source of truth for the comment-line shape: any future adjustment to the //-line grammar happens here and both the capturing and non-capturing forms stay in sync.



137
138
139
140
141
142
# File 'lib/coradoc/asciidoc/parser/text.rb', line 137

def comment_line_content
  tag.absent? >>
    str('//') >> str('/').absent? >>
    space? >>
    match('[^\n]').repeat(0) >> line_ending
end

#dateObject



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

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

#digitObject



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

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

#digitsObject



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

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

#emailObject



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

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

#empty_lineObject



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

def empty_line
  str("\n")
end

#endlineObject



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

def endline
  newline | any.absent?
end

#eof?Boolean

Returns:

  • (Boolean)


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

def eof?
  any.absent?
end

#file_pathObject



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

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

#include_directiveObject



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

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

#keywordObject



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

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

#line_endObject



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

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

#line_endingObject



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

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

#line_start?Boolean

Returns:

  • (Boolean)


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

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

#newlineObject

def endline_single newline_single | any.absent? end



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

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

#newline_singleObject



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

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

#rich_textObject



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

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

#rich_textsObject



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

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

#spaceObject



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

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

#space?Boolean

Returns:

  • (Boolean)


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

def space?
  space.maybe
end

#special_characterObject



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

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

#tagObject



153
154
155
156
157
158
159
160
161
162
# File 'lib/coradoc/asciidoc/parser/text.rb', line 153

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



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

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

#wordObject



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

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

#wordsObject



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

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