Module: Coradoc::Parser::Asciidoc::Inline
- Included in:
- Base
- Defined in:
- lib/coradoc/parser/asciidoc/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
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_constrained ⇒ Object
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_unconstrained ⇒ Object
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_constrained ⇒ Object
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_unconstrained ⇒ Object
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 |
#inline ⇒ Object
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
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_image ⇒ Object
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_constrained ⇒ Object
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_unconstrained ⇒ Object
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 |
#link ⇒ Object
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_constrained ⇒ Object
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_unconstrained ⇒ Object
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 |
#small ⇒ Object
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 |
#span ⇒ Object
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_constrained ⇒ Object
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_unconstrained ⇒ Object
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 |
#subscript ⇒ Object
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 |
#superscript ⇒ Object
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_any ⇒ Object
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_formatted ⇒ Object
181 182 183 |
# File 'lib/coradoc/parser/asciidoc/inline.rb', line 181 def text_formatted (inline_chars? >> inline) end |
#text_unformatted ⇒ Object
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 |
#underline ⇒ Object
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 |