Class: MarkdownIt::RulesInline::HtmlInline

Inherits:
Object
  • Object
show all
Includes:
Common::HtmlRe
Defined in:
lib/motion-markdown-it/rules_inline/html_inline.rb

Constant Summary

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

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 (state.src.charCodeAt(pos) != 0x3C || pos + 2 >= max)  #  < 
    return false
  end

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

  match = state.src.slice_to_end(pos).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