Module: Coradoc::Parser::Asciidoc::Inline

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

Instance Method Summary collapse

Instance Method Details

#attribute_referenceObject



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

def attribute_reference
  str("{").present? >> str("{") >>
    match("[a-zA-Z0-9_-]").repeat(1).as(:attribute_reference) >>
    str("}")
end

#bold_constrainedObject



11
12
13
14
15
16
17
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 11

def bold_constrained
  (str("*").present? >> str("*") >>
    match("[^*]").repeat(1).as(:text).repeat(1, 1) >>
     str("*") >> str("*").absent? >>
     str("\n\n").absent?
  ).as(:bold_constrained)
end

#bold_unconstrainedObject



19
20
21
22
23
24
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 19

def bold_unconstrained
  (str("**").present? >> str("**") >>
    match("[^*]").repeat(1).as(:text).repeat(1, 1) >>
     str("**")
  ).as(:bold_unconstrained)
end

#highlight_constrainedObject



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

def highlight_constrained
  (str("#") >>
    match("[^#]").repeat(1).as(:text).repeat(1, 1) >>
     str("#") >> str("#").absent?
  ).as(:highlight_constrained)
end

#highlight_unconstrainedObject



63
64
65
66
67
68
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 63

def highlight_unconstrained
  (str("##") >>
    match("[^#]").repeat(1).as(:text).repeat(1, 1) >>
     str("##")
  ).as(:highlight_unconstrained)
end

#inlineObject



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 150

def inline
  bold_unconstrained |
    bold_constrained |
    span_unconstrained |
    span_constrained |
    italic_unconstrained |
    italic_constrained |
    highlight_unconstrained |
    highlight_constrained |
    monospace_unconstrained |
    monospace_constrained |
    superscript |
    subscript |
    attribute_reference |
    cross_reference |
    term_inline |
    term_inline2 |
    footnote |
    link |
    inline_image |
    underline |
    small
end

#inline_chars?Boolean

Returns:

  • (Boolean)


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

def inline_chars?
  match('[\[*#_{<^~`]').present? |
    str("http").present? |
    str("https").present? |
    str("link:").present? |
    str("image:").present? |
    term_type.present? |
    str("footnote").present?
end

#inline_imageObject



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

def inline_image
  (str("image:").present? >> str("image:") >>
    match("[A-Za-z0-9_.\\-:/&?=+,%#~;]+").repeat(1).as(:path) >>
    (str("[") >> match("[^\\]]").repeat(1).as(:text) >> str("]")).maybe
  ).as(:inline_image)
end

#italic_constrainedObject



42
43
44
45
46
47
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 42

def italic_constrained
  (str("_") >> str("_").absent? >>
    match("[^_]").repeat(1).as(:text).repeat(1, 1) >>
     str("_") >> str("_").absent?
  ).as(:italic_constrained)
end

#italic_unconstrainedObject



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

def italic_unconstrained
  (str("__") >>
    match("[^_]").repeat(1).as(:text).repeat(1, 1) >>
     str("__")
  ).as(:italic_unconstrained)
end


106
107
108
109
110
111
112
113
114
115
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 106

def link
  ((str("http").present? | str("https").present? | str("ftp").present?) >>
    match("[A-Za-z0-9_.\\-:/&?=+,%#~;]+").repeat(1).as(:path) >>
    (str("[") >> match("[^\\]]").repeat(1).as(:text) >> str("]")).maybe
  ).as(:link) |
    (str("link:").present? >> str("link:") >>
      match("[A-Za-z0-9_.\\-:/&?=+,%#~;]+").repeat(1).as(:path) >>
      (str("[") >> match("[^\\]]").repeat(1).as(:text) >> str("]")).maybe
    ).as(:link)
end

#monospace_constrainedObject



70
71
72
73
74
75
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 70

def monospace_constrained
  (str("`") >>
    match("[^`]").repeat(1).as(:text).repeat(1, 1) >>
     str("`") >> str("`").absent?
  ).as(:monospace_constrained)
end

#monospace_unconstrainedObject



77
78
79
80
81
82
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 77

def monospace_unconstrained
  (str("``") >>
    match("[^`]").repeat(1).as(:text).repeat(1, 1) >>
     str("``")
  ).as(:monospace_unconstrained)
end

#smallObject



132
133
134
135
136
137
138
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 132

def small
  (attribute_list >> match("\\[.small\\]").as(:role) >>
    str("#") >>
    match("[^#]").repeat(1).as(:text) >>
    str("#")
  ).as(:small)
end

#spanObject



98
99
100
101
102
103
104
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 98

def span
  attribute_list >>
    (str("#") >>
      match("[^#]").repeat(1).as(:text) >>
       str("#") >> str("#").absent?
    ).as(:span)
end

#span_constrainedObject



26
27
28
29
30
31
32
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 26

def span_constrained
  (attribute_list >>
    str("#") >>
    match("[^#]").repeat(1).as(:text) >>
     str("#") >> str("#").absent?
  ).as(:span_constrained)
end

#span_unconstrainedObject



34
35
36
37
38
39
40
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 34

def span_unconstrained
  (attribute_list >>
    str("##") >>
    match("[^#]").repeat(1).as(:text) >>
     str("##")
  ).as(:span_unconstrained)
end

#subscriptObject



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

def subscript
  (str("~") >>
    match("[^~]").repeat(1).as(:text).repeat(1, 1) >>
     str("~")
  ).as(:subscript)
end

#superscriptObject



84
85
86
87
88
89
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 84

def superscript
  (str("^") >>
    match("[^^]").repeat(1).as(:text).repeat(1, 1) >>
     str("^")
  ).as(:superscript)
end

#text_anyObject



185
186
187
188
189
190
191
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 185

def text_any
  (text_formatted |
          text_unformatted.as(:text)
  ).repeat(2) |
    text_formatted.repeat(1, 1) |
    text_unformatted
end

#text_formattedObject



181
182
183
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 181

def text_formatted
  (inline_chars? >> inline)
end

#text_unformattedObject



174
175
176
177
178
179
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 174

def text_unformatted
  # line_not_text? >>
  (inline.absent? >>
    match("[^\n]")
  ).repeat(1)
end

#underlineObject



124
125
126
127
128
129
130
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 124

def underline
  (attribute_list >> match("\\[.underline\\]").as(:role) >>
    str("#") >>
    match("[^#]").repeat(1).as(:text) >>
    str("#")
  ).as(:underline)
end