Module: Coradoc::AsciiDoc::Parser::Inline
- Defined in:
- lib/coradoc/asciidoc/parser/inline.rb
Instance Method Summary collapse
- #attribute_reference ⇒ Object
- #bold_constrained ⇒ Object
- #bold_unconstrained ⇒ Object
- #highlight_constrained ⇒ Object
- #highlight_unconstrained ⇒ Object
- #inline ⇒ Object
- #inline_chars? ⇒ Boolean
- #inline_image ⇒ Object
- #italic_constrained ⇒ Object
- #italic_unconstrained ⇒ Object
- #link ⇒ Object
- #monospace_constrained ⇒ Object
- #monospace_unconstrained ⇒ Object
- #small ⇒ Object
- #span ⇒ Object
- #span_constrained ⇒ Object
- #span_unconstrained ⇒ Object
- #subscript ⇒ Object
- #superscript ⇒ Object
- #text_any ⇒ Object
- #text_formatted ⇒ Object
- #text_unformatted ⇒ Object
- #underline ⇒ Object
Instance Method Details
#attribute_reference ⇒ Object
7 8 9 10 11 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 7 def attribute_reference str('{').present? >> str('{') >> match('[a-zA-Z0-9_-]').repeat(1).as(:attribute_reference) >> str('}') end |
#bold_constrained ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 13 def bold_constrained (str('*').present? >> str('*') >> match('[^*\n]').repeat(1).as(:text).repeat(1, 1) >> str('*') >> str('*').absent? >> str("\n\n").absent? ).as(:bold_constrained) end |
#bold_unconstrained ⇒ Object
21 22 23 24 25 26 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 21 def bold_unconstrained (str('**').present? >> str('**') >> match('[^*\n]').repeat(1).as(:text).repeat(1, 1) >> str('**') ).as(:bold_unconstrained) end |
#highlight_constrained ⇒ Object
58 59 60 61 62 63 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 58 def highlight_constrained (str('#') >> match('[^#\n]').repeat(1).as(:text).repeat(1, 1) >> str('#') >> str('#').absent? ).as(:highlight_constrained) end |
#highlight_unconstrained ⇒ Object
65 66 67 68 69 70 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 65 def highlight_unconstrained (str('##') >> match('[^#\n]').repeat(1).as(:text).repeat(1, 1) >> str('##') ).as(:highlight_unconstrained) end |
#inline ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 153 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 | stem | link | inline_image | underline | small end |
#inline_chars? ⇒ Boolean
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 142 def inline_chars? match('[\[*#_{<^~`]').present? | str('http').present? | str('https').present? | str('link:').present? | str('image:').present? | term_type.present? | str('footnote').present? | stem_type.present? end |
#inline_image ⇒ Object
119 120 121 122 123 124 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 119 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_constrained ⇒ Object
44 45 46 47 48 49 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 44 def italic_constrained (str('_') >> str('_').absent? >> match('[^_\n]').repeat(1).as(:text).repeat(1, 1) >> str('_') >> str('_').absent? ).as(:italic_constrained) end |
#italic_unconstrained ⇒ Object
51 52 53 54 55 56 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 51 def italic_unconstrained (str('__') >> match('[^_\n]').repeat(1).as(:text).repeat(1, 1) >> str('__') ).as(:italic_unconstrained) end |
#link ⇒ Object
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 108 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_constrained ⇒ Object
72 73 74 75 76 77 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 72 def monospace_constrained (str('`') >> match('[^`\n]').repeat(1).as(:text).repeat(1, 1) >> str('`') >> str('`').absent? ).as(:monospace_constrained) end |
#monospace_unconstrained ⇒ Object
79 80 81 82 83 84 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 79 def monospace_unconstrained (str('``') >> match('[^`\n]').repeat(1).as(:text).repeat(1, 1) >> str('``') ).as(:monospace_unconstrained) end |
#small ⇒ Object
134 135 136 137 138 139 140 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 134 def small (attribute_list >> match('\\[.small\\]').as(:role) >> str('#') >> match('[^#\n]').repeat(1).as(:text) >> str('#') ).as(:small) end |
#span ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 100 def span attribute_list >> (str('#') >> match('[^#\n]').repeat(1).as(:text) >> str('#') >> str('#').absent? ).as(:span) end |
#span_constrained ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 28 def span_constrained (attribute_list >> str('#') >> match('[^#\n]').repeat(1).as(:text) >> str('#') >> str('#').absent? ).as(:span_constrained) end |
#span_unconstrained ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 36 def span_unconstrained (attribute_list >> str('##') >> match('[^#\n]').repeat(1).as(:text) >> str('##') ).as(:span_unconstrained) end |
#subscript ⇒ Object
93 94 95 96 97 98 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 93 def subscript (str('~') >> match('[^~\n]').repeat(1).as(:text).repeat(1, 1) >> str('~') ).as(:subscript) end |
#superscript ⇒ Object
86 87 88 89 90 91 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 86 def superscript (str('^') >> match('[^^\n]').repeat(1).as(:text).repeat(1, 1) >> str('^') ).as(:superscript) end |
#text_any ⇒ Object
189 190 191 192 193 194 195 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 189 def text_any (text_formatted | text_unformatted.as(:text) ).repeat(2) | text_formatted.repeat(1, 1) | text_unformatted end |
#text_formatted ⇒ Object
185 186 187 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 185 def text_formatted (inline_chars? >> inline) end |
#text_unformatted ⇒ Object
178 179 180 181 182 183 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 178 def text_unformatted # line_not_text? >> (inline.absent? >> match("[^\n]") ).repeat(1) end |
#underline ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/coradoc/asciidoc/parser/inline.rb', line 126 def underline (attribute_list >> match('\\[.underline\\]').as(:role) >> str('#') >> match('[^#\n]').repeat(1).as(:text) >> str('#') ).as(:underline) end |