1
0

html.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. module Docs
  2. class Html < Mdn
  3. prepend FixInternalUrlsBehavior
  4. self.name = 'HTML'
  5. self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/HTML'
  6. html_filters.push 'html/clean_html', 'html/entries', 'title'
  7. options[:root_title] = 'HTML'
  8. options[:title] = ->(filter) do
  9. if filter.slug == 'Element/Heading_Elements'
  10. 'Heading Elements'
  11. elsif filter.slug.start_with?('Element/')
  12. "<#{filter.default_title}>"
  13. else
  14. filter.default_title
  15. end
  16. end
  17. options[:skip] = %w(
  18. /index
  19. /Element/shadow
  20. /Element/webkit-meter-optimum-value
  21. )
  22. options[:replace_paths] = {
  23. '/Element/h1' => '/Element/Heading_Elements',
  24. '/Element/h2' => '/Element/Heading_Elements',
  25. '/Element/h3' => '/Element/Heading_Elements',
  26. '/Element/h4' => '/Element/Heading_Elements',
  27. '/Element/h5' => '/Element/Heading_Elements',
  28. '/Element/h6' => '/Element/Heading_Elements',
  29. '/Global_attributes/data-%2A' => '/Global_attributes/data-*' }
  30. options[:fix_urls] = ->(url) do
  31. url.sub! 'https://developer.mozilla.org/en-US/docs/HTML/', "#{Html.base_url}/" unless url.include?('Content_categories')
  32. url
  33. end
  34. end
  35. end