github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/images/jekyll/checks.rb (about) 1 #!/usr/local/bin/ruby 2 # 3 # HTMLProofer checks for the gVisor website. 4 # 5 require 'html-proofer' 6 7 # NoOpenerCheck checks to make sure links with target=_blank include the 8 # rel=noopener attribute. 9 class NoOpenerCheck < ::HTMLProofer::Check 10 def run 11 @html.css('a').each do |node| 12 link = create_element(node) 13 line = node.line 14 15 rel = link.respond_to?(:rel) ? link.rel.split(' ') : [] 16 17 if link.respond_to?(:target) && link.target == "_blank" && !rel.include?("noopener") 18 return add_issue("You should set rel=noopener for links with target=_blank", line: line) 19 end 20 end 21 end 22 end 23 24 def main() 25 options = { 26 :check_html => true, 27 :check_favicon => true, 28 :disable_external => true, 29 } 30 31 HTMLProofer.check_directories(ARGV, options).run 32 end 33 34 if __FILE__ == $0 35 main 36 end