Class: MaRuKu::In::Markdown::SpanLevelParser::CharSourceStrscan
- Includes:
- MaRuKu::In::Markdown::SpanLevelParser, Strings
- Defined in:
- lib/amp-front/third_party/maruku/input/charsource.rb,
lib/amp-front/third_party/maruku/input/charsource.rb
Overview
a wrapper around StringScanner
Constant Summary
Constants included from Strings
Strings::Abbreviation, Strings::AttributeDefinitionList, Strings::Definition, Strings::EMailAddress, Strings::FootnoteText, Strings::HeaderWithAttributes, Strings::HeaderWithId, Strings::IncompleteLink, Strings::InlineAttributeList, Strings::LinkRegex, Strings::MightBeTableHeader, Strings::Sep, Strings::TabSize, Strings::TableSeparator
Constants included from MaRuKu::In::Markdown::SpanLevelParser
CharSource, Close_class, EscapedCharInInlineCode, EscapedCharInQuotes, EscapedCharInText, Punct_class, R_REF_ID, Rules, SPACE
Instance Method Summary collapse
- #consume_whitespace ⇒ Object
-
#cur_char ⇒ Object
Return current char as a FixNum (or nil).
-
#cur_chars(n) ⇒ Object
Return the next n chars as a String.
- #cur_chars_are(string) ⇒ Object
- #current_remaining_buffer ⇒ Object
- #describe ⇒ Object
- #ignore_char ⇒ Object
- #ignore_chars(n) ⇒ Object
-
#initialize(s, parent = nil) ⇒ CharSourceStrscan
constructor
A new instance of CharSourceStrscan.
-
#next_char ⇒ Object
Return the char after current char as a FixNum (or nil).
- #next_matches(r) ⇒ Object
- #read_regexp(r) ⇒ Object
- #shift_char ⇒ Object
Methods included from Strings
#add_tabs, #dbg_describe_ary, #force_linebreak?, #line_md_type, #normalize_key_and_value, #num_leading_hashes, #number_of_leading_spaces, #parse_email_headers, #sanitize_ref_id, #spaces_before_first_char, #split_lines, #strip_hashes, #strip_indent, #unquote
Methods included from MaRuKu::In::Markdown::SpanLevelParser
#apply_one_rule, #describe_pos, #educate, #extension_meta, #interpret_extension, #is_ial, #md_al, #merge_ial, #parse_lines_as_span, #parse_span_better, #read_attribute_list, #read_em, #read_email_el, #read_emstrong, #read_footnote_ref, #read_image, #read_inline_code, #read_inline_html, #read_link, #read_quoted, #read_quoted_or_unquoted, #read_ref_id, #read_simple, #read_span, #read_strong, #read_url, #read_url_el, #read_xml_instr_span, #unit_tests_for_attribute_lists
Methods included from Helpers
#md_abbr, #md_abbr_def, #md_ald, #md_br, #md_code, #md_codeblock, #md_el, #md_em, #md_email, #md_emstrong, #md_entity, #md_foot_ref, #md_footnote, #md_header, #md_hrule, #md_html, #md_ial, #md_im_image, #md_im_link, #md_image, #md_li, #md_link, #md_par, #md_quote, #md_ref_def, #md_strong, #md_url, #md_xml_instr
Constructor Details
#initialize(s, parent = nil) ⇒ CharSourceStrscan
Returns a new instance of CharSourceStrscan.
208 209 210 211 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 208 def initialize(s, parent=nil) @s = StringScanner.new(s) @parent = parent end |
Instance Method Details
#consume_whitespace ⇒ Object
264 265 266 267 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 264 def consume_whitespace @s.scan(/\s+/) nil end |
#cur_char ⇒ Object
Return current char as a FixNum (or nil).
214 215 216 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 214 def cur_char @s.peek(1)[0] end |
#cur_chars(n) ⇒ Object
Return the next n chars as a String.
219 220 221 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 219 def cur_chars(n); @s.peek(n) end |
#cur_chars_are(string) ⇒ Object
246 247 248 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 246 def cur_chars_are(string) cur_chars(string.size) == string end |
#current_remaining_buffer ⇒ Object
242 243 244 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 242 def current_remaining_buffer @s.rest #nil #@buffer[@buffer_index, @buffer.size-@buffer_index] end |
#describe ⇒ Object
269 270 271 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 269 def describe describe_pos(@s.string, @s.pos) end |
#ignore_char ⇒ Object
232 233 234 235 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 232 def ignore_char @s.get_byte nil end |
#ignore_chars(n) ⇒ Object
237 238 239 240 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 237 def ignore_chars(n) n.times do @s.get_byte end nil end |
#next_char ⇒ Object
Return the char after current char as a FixNum (or nil).
224 225 226 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 224 def next_char; @s.peek(2)[1] end |
#next_matches(r) ⇒ Object
250 251 252 253 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 250 def next_matches(r) len = @s.match?(r) return !!len end |
#read_regexp(r) ⇒ Object
255 256 257 258 259 260 261 262 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 255 def read_regexp(r) string = @s.scan(r) if string return r.match(string) else return nil end end |
#shift_char ⇒ Object
228 229 230 |
# File 'lib/amp-front/third_party/maruku/input/charsource.rb', line 228 def shift_char (@s.get_byte)[0] end |