Class: MarkdownIt::RulesInline::Entity
- Inherits:
-
Object
- Object
- MarkdownIt::RulesInline::Entity
- Extended by:
- Common::Utils
- Defined in:
- lib/motion-markdown-it/rules_inline/entity.rb
Constant Summary collapse
- DIGITAL_RE =
/^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i
- NAMED_RE =
/^&([a-z][a-z0-9]{1,31});/i
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
-
.entity(state, silent) ⇒ Object
——————————————————————————.
Methods included from Common::Utils
arrayReplaceAt, assign, escapeHtml, escapeRE, fromCharCode, fromCodePoint, isMdAsciiPunct, isPunctChar, isSpace, isValidEntityCode, isWhiteSpace, normalizeReference, replaceEntityPattern, unescapeAll, unescapeMd
Class Method Details
.entity(state, silent) ⇒ Object
13 14 15 16 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 47 |
# File 'lib/motion-markdown-it/rules_inline/entity.rb', line 13 def self.entity(state, silent) pos = state.pos max = state.posMax return false if state.src.charCodeAt(pos) != 0x26 # & if pos + 1 < max ch = state.src.charCodeAt(pos + 1) if ch == 0x23 # '#' match = state.src.slice_to_end(pos).match(DIGITAL_RE) if match if !silent code = match[1][0].downcase == 'x' ? match[1].slice_to_end(1).to_i(16) : match[1].to_i state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD) end state.pos += match[0].length return true end else match = state.src.slice_to_end(pos).match(NAMED_RE) if match if MarkdownIt::HTMLEntities::MAPPINGS[match[1]] state.pending += fromCodePoint(MarkdownIt::HTMLEntities::MAPPINGS[match[1]]) if !silent state.pos += match[0].length return true end end end end state.pending += '&' if !silent state.pos += 1 return true end |