class MarkdownIt::RulesInline::HtmlInline

Public Class Methods

html_inline(state, silent) click to toggle source
# 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) click to toggle source
# 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