|
|
@@ -2,50 +2,38 @@ module Docs
|
|
|
class Jekyll
|
|
|
class CleanHtmlFilter < Filter
|
|
|
def call
|
|
|
- css('.improve, .section-nav').each(&:remove)
|
|
|
+ @doc = at_css('article')
|
|
|
+
|
|
|
+ at_css('h1').content = 'Jekyll' if root_page?
|
|
|
+
|
|
|
+ css('.improve, .section-nav').remove
|
|
|
|
|
|
css('div.highlighter-rouge').each do |node|
|
|
|
pre = node.at_css('pre')
|
|
|
|
|
|
- # copy over the highlighting metadata
|
|
|
- match = /language-(\w+)/.match(node['class'])
|
|
|
+ lang = node['class'][/language-(\w+)/, 1]
|
|
|
# HACK: Prism shell highlighting highlights `|`,
|
|
|
# which makes the tree on this page look terrible
|
|
|
- if match && !(slug == /structure/ && match[1] == 'sh')
|
|
|
- lang = match[1]
|
|
|
- if lang == 'sh'
|
|
|
- lang = 'bash'
|
|
|
- elsif lang == 'liquid'
|
|
|
- lang = 'django' # Close enough.
|
|
|
- end
|
|
|
- pre['class'] = nil
|
|
|
+ unless slug.include?('structure') && lang == 'sh'
|
|
|
+ lang = 'bash' if lang == 'sh'
|
|
|
pre['data-language'] = lang
|
|
|
end
|
|
|
|
|
|
- # Remove the server-rendered syntax highlighting
|
|
|
- code = pre.at_css('code')
|
|
|
- code.content = code.text
|
|
|
-
|
|
|
- # Remove the div.highlighter-rouge and div.highlight wrapping the <pre>
|
|
|
- node.add_next_sibling pre
|
|
|
- node.remove
|
|
|
+ pre.remove_attribute('class')
|
|
|
+ pre.content = pre.content
|
|
|
+ node.replace(pre)
|
|
|
end
|
|
|
|
|
|
- css('code').each do |node|
|
|
|
- node['class'] = ''
|
|
|
- end
|
|
|
+ css('code').remove_attr('class')
|
|
|
|
|
|
css('.note').each do |node|
|
|
|
- node_type = /note ?(\w+)?/.match(node['class'])[1] || 'tip'
|
|
|
+ node.name = 'blockquote'
|
|
|
|
|
|
# <div class="note">...<br>...</div> -> <div class="note">...</div>
|
|
|
(node > 'br').each(&:remove)
|
|
|
# <div class="note">...<p>...<br><br>...</p>...</div> ->
|
|
|
# <div class="note">...<p>...<br>...</p>...</div>
|
|
|
node.css('br + br').each(&:remove)
|
|
|
-
|
|
|
- node['class'] = "note note-#{node_type}"
|
|
|
- node['data-type'] = node_type
|
|
|
end
|
|
|
|
|
|
doc
|