Class: MarkdownIt::RulesInline::Text

Inherits:
Object
  • Object
show all
Extended by:
Common::Utils
Defined in:
lib/motion-markdown-it/rules_inline/text.rb

Constant Summary

Constants included from Common::Utils

Common::Utils::DIGITAL_ENTITY_TEST_RE, Common::Utils::ENTITY_RE, Common::Utils::HTML_ESCAPE_REPLACE_RE, Common::Utils::HTML_ESCAPE_TEST_RE, Common::Utils::HTML_REPLACEMENTS, Common::Utils::REGEXP_ESCAPE_RE, Common::Utils::UNESCAPE_ALL_RE, Common::Utils::UNESCAPE_MD_RE, Common::Utils::UNICODE_PUNCT_RE

Class Method Summary collapse

Methods included from Common::Utils

arrayReplaceAt, assign, charCodeAt, escapeHtml, escapeRE, fromCharCode, fromCodePoint, isMdAsciiPunct, isPunctChar, isSpace, isValidEntityCode, isWhiteSpace, normalizeReference, replaceEntityPattern, unescapeAll, unescapeMd

Class Method Details

.isTerminatorChar(ch) ⇒ Object

!!!! Don’t confuse with “Markdown ASCII Punctuation” chars spec.commonmark.org/0.15/#ascii-punctuation-character




17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/motion-markdown-it/rules_inline/text.rb', line 17

def self.isTerminatorChar(ch)
  case ch
  when 0x0A,    # \n
       0x21,    # !
       0x23,    # #
       0x24,    # $
       0x25,    # %
       0x26,    # &
       0x2A,    # *
       0x2B,    # +
       0x2D,    # -
       0x3A,    # :
       0x3C,    # <
       0x3D,    # =
       0x3E,    # >
       0x40,    # @
       0x5B,    # [
       0x5C,    # \
       0x5D,    # ]
       0x5E,    # ^
       0x5F,    # _
       0x60,    # `
       0x7B,    # {
       0x7D,    # }
       0x7E     # ~
    return true
  else
    return false
  end
end

.text(state, silent) ⇒ Object




49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/motion-markdown-it/rules_inline/text.rb', line 49

def self.text(state, silent)
  pos = state.pos

  while pos < state.posMax && !self.isTerminatorChar(charCodeAt(state.src, pos))
    pos += 1
  end

  return false if pos == state.pos

  state.pending += state.src.slice(state.pos...pos) if !silent
  state.pos      = pos
  return true
end