|
|
|
@ -2,26 +2,9 @@ module Docs
|
|
|
|
|
class Sequelize
|
|
|
|
|
class CleanHtmlFilter < Filter
|
|
|
|
|
def call
|
|
|
|
|
@doc = at_css('.content')
|
|
|
|
|
@doc = at_css('article', '.content')
|
|
|
|
|
|
|
|
|
|
# Clean up the home page
|
|
|
|
|
if root_page? || subpath == "index.html"
|
|
|
|
|
# Remove logo
|
|
|
|
|
css('.manual-user-index > div > div.logo').remove
|
|
|
|
|
|
|
|
|
|
# Convert title to proper h1 element
|
|
|
|
|
at_css('.manual-user-index > div > div.sequelize').name = 'h1'
|
|
|
|
|
|
|
|
|
|
# Remove badges (NPM, Travis, test coverage, etc.)
|
|
|
|
|
css('.manual-user-index > p:nth-child(4)').remove
|
|
|
|
|
|
|
|
|
|
# Remove image cards pointing to entries of the manual
|
|
|
|
|
css('.manual-cards').remove
|
|
|
|
|
|
|
|
|
|
# Pull the header out of its container
|
|
|
|
|
header = at_css('h1')
|
|
|
|
|
header.parent.parent.parent.add_previous_sibling header
|
|
|
|
|
else
|
|
|
|
|
if at_css('header > h1')
|
|
|
|
|
# Pull the header out of its container
|
|
|
|
|
header = at_css('h1')
|
|
|
|
|
header.parent.add_previous_sibling header
|
|
|
|
@ -36,18 +19,13 @@ module Docs
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Add syntax highlighting to code blocks
|
|
|
|
|
css('pre > code[class^="lang-"]').each do |node|
|
|
|
|
|
pre = node.parent
|
|
|
|
|
# Convert the existing language definitions to Prism-compatible attributes
|
|
|
|
|
pre['data-language'] = 'javascript' if node['class'] == 'lang-js' || node['class'] == 'lang-javascript'
|
|
|
|
|
pre['data-language'] = 'json' if node['class'] == 'lang-json'
|
|
|
|
|
pre['data-language'] = 'shell' if node['class'] == 'lang-sh' || node['class'] == 'lang-bash'
|
|
|
|
|
pre['data-language'] = 'sql' if node['class'] == 'lang-sql'
|
|
|
|
|
pre['data-language'] = 'typescript' if node['class'] == 'lang-ts'
|
|
|
|
|
css('pre[class^="prism-code language-"]').each do |node|
|
|
|
|
|
node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class'] and node['class'][/language-(\w+)/]
|
|
|
|
|
node.content = node.css('.token-line').map(&:content).join("\n")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Return the cleaned-up document
|
|
|
|
|
doc
|
|
|
|
|
at_css('.markdown') || doc
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|