Improve GitHub scraper

pull/656/head
Thibaut Courouble 8 years ago
parent 80cc88cef0
commit 85fffdc242

@ -1,9 +0,0 @@
#= require views/pages/base
class app.views.GithubPage extends app.views.BasePage
LANGUAGE_RGX = /highlight-source-(\w+)/
prepare: ->
for el in @findAll('pre.highlight')
@highlightCode(el, el.className.match(LANGUAGE_RGX)[1])
return

@ -28,6 +28,7 @@ app.views.EmberPage =
app.views.ErlangPage =
app.views.ExpressPage =
app.views.FlowPage =
app.views.GithubPage =
app.views.GoPage =
app.views.ImmutablePage =
app.views.InfluxdataPage =

@ -8,11 +8,15 @@ module Docs
end
css('.highlight > pre').each do |node|
node['class'] = node.parent['class']
node['data-language'] = node.parent['class'][/highlight-source-(\w+)/, 1]
node.content = node.content.strip_heredoc.gsub(' ', ' ')
node.parent.replace(node)
end
css('pre > code').each do |node|
node.before(node.children).remove
end
doc
end
end

@ -8,6 +8,10 @@ module Docs
node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
end
css('a > img').each do |node|
node.parent.before(node.parent.children).remove
end
doc
end
end

Loading…
Cancel
Save