mirror of https://github.com/freeCodeCamp/devdocs
parent
eabd270a94
commit
7cade1d4fc
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 56 KiB |
@ -0,0 +1,30 @@
|
||||
module Docs
|
||||
class Xpath
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
root_page? ? root : other
|
||||
doc
|
||||
end
|
||||
|
||||
def root
|
||||
if table = at_css('.topicpage-table')
|
||||
table.after(table.css('td').children).remove
|
||||
end
|
||||
end
|
||||
|
||||
def other
|
||||
css('div[style*="background: #f5f5f5;"]').remove
|
||||
|
||||
css('h3[id]').each do |node|
|
||||
node.name = 'h2'
|
||||
end
|
||||
|
||||
css('p').each do |node|
|
||||
child = node.child
|
||||
child = child.next while child && child.text? && child.content.blank?
|
||||
child.remove if child.try(:name) == 'br'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,22 @@
|
||||
module Docs
|
||||
class Xpath
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = super
|
||||
name.remove!('Axes.')
|
||||
name << '()' if name.remove!('Functions.')
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
if slug.start_with?('Axes')
|
||||
'Axes'
|
||||
elsif slug.start_with?('Functions')
|
||||
'Functions'
|
||||
else
|
||||
'Miscellaneous'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,16 @@
|
||||
module Docs
|
||||
class Xpath < Mdn
|
||||
self.name = 'XPath'
|
||||
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/XPath'
|
||||
|
||||
html_filters.push 'xpath/clean_html', 'xpath/entries', 'title'
|
||||
|
||||
options[:root_title] = 'XPath'
|
||||
|
||||
options[:fix_urls] = ->(url) do
|
||||
url.sub! 'https://developer.mozilla.org/en/XPath', Xpath.base_url
|
||||
url.sub! 'https://developer.mozilla.org/en-US/docs/XPath', Xpath.base_url
|
||||
url
|
||||
end
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 324 B |
After Width: | Height: | Size: 659 B |
Loading…
Reference in new issue