go.rb 699 B

1234567891011121314151617181920212223242526
  1. module Docs
  2. class Go < UrlScraper
  3. self.type = 'go'
  4. self.release = '1.5.2'
  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[:container] = '#page .container'
  12. options[:attribution] = <<-HTML
  13. &copy; Google, Inc.<br>
  14. Licensed under the Creative Commons Attribution License 3.0.
  15. HTML
  16. private
  17. def parse(html) # Hook here because Nokogori removes whitespace from textareas
  18. super html.gsub %r{<textarea\ class="code"[^>]*>([\W\w]+?)</textarea>}, '<pre class="code">\1</pre>'
  19. end
  20. end
  21. end