go.rb 735 B

123456789101112131415161718192021222324252627
  1. module Docs
  2. class Go < UrlScraper
  3. self.type = 'go'
  4. self.release = '1.7.0'
  5. self.base_url = 'https://golang.org/pkg/'
  6. self.links = {
  7. home: 'https://golang.org/',
  8. code: 'https://go.googlesource.com/go'
  9. }
  10. html_filters.push 'go/clean_html', 'go/entries'
  11. options[:trailing_slash] = true
  12. options[:container] = '#page .container'
  13. options[:attribution] = <<-HTML
  14. &copy; Google, Inc.<br>
  15. Licensed under the Creative Commons Attribution License 3.0.
  16. HTML
  17. private
  18. def parse(html) # Hook here because Nokogori removes whitespace from textareas
  19. super html.gsub %r{<textarea\ class="code"[^>]*>([\W\w]+?)</textarea>}, '<pre class="code">\1</pre>'
  20. end
  21. end
  22. end