Skip to content

Commit 4dc9557

Browse files
committed
mdn: update scraper to mdn/yari
1 parent 92d8a8e commit 4dc9557

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

assets/stylesheets/pages/_mdn.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
p > code, li > code { @extend %label; }
2828

2929
> .note,
30+
.notecard, // MDN 2021
3031
.notice,
3132
.warning,
3233
.overheadIndicator,

lib/docs/filters/mdn/clean_html.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ def call
4141
node.parent['id'] = node['name']
4242
node.before(node.content).remove
4343
end
44+
css('h2 > a, h3 > a').each do |node|
45+
node.parent.content = node.content
46+
end
47+
48+
css('.notecard > h4').each do |node|
49+
node.name = 'strong'
50+
end
51+
52+
css('svg.deprecated').each do |node|
53+
node.name = 'span'
54+
node.content = node.content
55+
end
4456

4557
css('dt > a[id]').each do |node|
4658
next if node['href']
@@ -64,6 +76,9 @@ def call
6476
end
6577

6678
# New compatibility tables
79+
# FIXME(2021):
80+
# - fetched from external JSON: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/alignment-baseline/bcd.json
81+
# - https://github.com/mdn/yari/blob/master/build/bcd-urls.js
6782

6883
css('.bc-data #Legend + dl', '.bc-data #Legend', '.bc-data #Legend_2 + dl', '.bc-data #Legend_2', '.bc-browser-name').remove
6984

lib/docs/filters/svg/clean_html.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def root
1111
end
1212

1313
def other
14-
css('.prevnext').remove
14+
css('.prev-next').remove
1515

1616
if at_css('p').content.include?("\u{00AB}")
1717
at_css('p').remove

lib/docs/scrapers/mdn/mdn.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ class Mdn < UrlScraper
33
self.abstract = true
44
self.type = 'mdn'
55

6-
params[:raw] = 1
7-
params[:macros] = 1
8-
96
html_filters.push 'mdn/clean_html'
107

11-
options[:rate_limit] = 200
8+
options[:container] = '#content'
129
options[:trailing_slash] = false
1310

1411
options[:skip_link] = ->(link) {
@@ -23,12 +20,5 @@ class Mdn < UrlScraper
2320
def get_latest_version(opts)
2421
get_latest_github_commit_date('mdn', 'content', opts)
2522
end
26-
27-
private
28-
29-
def process_response?(response)
30-
response.effective_url.host = 'developer.mozilla.org' if response.effective_url.host == 'wiki.developer.mozilla.org'
31-
super && response.effective_url.query == 'raw=1&macros=1'
32-
end
3323
end
3424
end

0 commit comments

Comments
 (0)