Class: MarkdownIt::RulesInline::HtmlInline

Inherits:
Object
  • Object
show all
Extended by:
Common::Utils
Includes:
Common::HtmlRe
Defined in:
lib/motion-markdown-it/rules_inline/html_inline.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

Constants included from Common::HtmlRe

Common::HtmlRe::ATTRIBUTE, Common::HtmlRe::ATTR_NAME, Common::HtmlRe::ATTR_VALUE, Common::HtmlRe::CDATA, Common::HtmlRe::CLOSE_TAG, Common::HtmlRe::COMMENT, Common::HtmlRe::DECLARATION, Common::HtmlRe::DOUBLE_QUOTED, Common::HtmlRe::HTML_OPEN_CLOSE_TAG_RE, Common::HtmlRe::HTML_TAG_RE, Common::HtmlRe::OPEN_TAG, Common::HtmlRe::PROCESSING, Common::HtmlRe::SINGLE_QUOTED, Common::HtmlRe::UNQUOTED

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

.html_inline(state, silent) ⇒ Object




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
# File 'lib/motion-markdown-it/rules_inline/html_inline.rb', line 16

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

  return false if !state.md.options[:html]

  # Check start
  max = state.posMax
  if (charCodeAt(state.src, pos) != 0x3C || pos + 2 >= max)  #  <
    return false
  end

  # Quick fail on second char
  ch = charCodeAt(state.src, pos + 1)
  if (ch != 0x21 &&  # !
      ch != 0x3F &&  # ?
      ch != 0x2F &&  # /
      !isLetter(ch))
    return false
  end

  match = state.src[pos..-1].match(HTML_TAG_RE)
  return false if !match

  if !silent
    token         = state.push('html_inline', '', 0)
    token.content = state.src.slice(pos...(pos + match[0].length))
  end
  state.pos += match[0].length
  return true
end

.isLetter(ch) ⇒ Object




10
11
12
13
# File 'lib/motion-markdown-it/rules_inline/html_inline.rb', line 10

def self.isLetter(ch)
  lc = ch | 0x20    # to lower case
  return (lc >= 0x61) && (lc <= 0x7a)  # >= a && <= z
end