class Kramdown::Parser::NoopenerGFM

Constants

SAFE_OPTS

Public Class Methods

new(source, options) click to toggle source
Calls superclass method
# File lib/kramdown/parser/noopener_gfm.rb, line 7
def initialize(source, options)
  super
  @same_tab_domains = options.fetch(:same_tab_domains, [])
end

Public Instance Methods

update_elements(element) click to toggle source
Calls superclass method
# File lib/kramdown/parser/noopener_gfm.rb, line 12
def update_elements(element)
  if element.type == :a && \
     element.attr.respond_to?(:[]) && \
     (href = element.attr['href']) && \
     URI::DEFAULT_PARSER.regexp[:ABS_URI].match(href) && \
     !@same_tab_domains.include?(URI::parse(href).host)

    element.attr.merge!(SAFE_OPTS)
  end
  super
end