|
|
|
@ -2,15 +2,14 @@ module Docs
|
|
|
|
|
class Typescript
|
|
|
|
|
class CleanHtmlFilter < Filter
|
|
|
|
|
|
|
|
|
|
def call
|
|
|
|
|
if slug.include?('index')
|
|
|
|
|
root
|
|
|
|
|
elsif slug == ('tsconfig/')
|
|
|
|
|
tsconfig
|
|
|
|
|
else
|
|
|
|
|
other
|
|
|
|
|
end
|
|
|
|
|
LANGUAGE_REPLACE = {
|
|
|
|
|
'cmd' => 'shell',
|
|
|
|
|
'sh' => 'shell',
|
|
|
|
|
'tsx' => 'typescript+html'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def call
|
|
|
|
|
root_page? ? root : other
|
|
|
|
|
doc
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -24,23 +23,25 @@ module Docs
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def other
|
|
|
|
|
@doc = at_css('article > .whitespace > .markdown')
|
|
|
|
|
if base_url.path == '/docs/handbook/'
|
|
|
|
|
@doc = at_css('article > .whitespace > .markdown')
|
|
|
|
|
else # tsconfig page
|
|
|
|
|
@doc = at_css('.markdown > div')
|
|
|
|
|
|
|
|
|
|
css('.anchor').remove
|
|
|
|
|
at_css('h2').remove
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
css('.anchor', 'a:contains("Try")', 'h2 a', 'h3 a', 'svg', '#full-option-list').remove
|
|
|
|
|
|
|
|
|
|
css('a:contains("Try")').remove
|
|
|
|
|
css('pre').each do |node|
|
|
|
|
|
language = node.at_css('.language-id') ? node.at_css('.language-id').content : 'typescript'
|
|
|
|
|
node.css('.language-id').remove
|
|
|
|
|
node.content = node.content
|
|
|
|
|
node['data-language'] = 'typescript'
|
|
|
|
|
node['data-language'] = LANGUAGE_REPLACE[language] || language
|
|
|
|
|
node.remove_attribute('class')
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def tsconfig
|
|
|
|
|
css('h2 a', 'h3 a').remove
|
|
|
|
|
css('svg').remove
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|