diff --git a/lib/docs/filters/vue/clean_html.rb b/lib/docs/filters/vue/clean_html.rb index b2784d3e..ae12d743 100644 --- a/lib/docs/filters/vue/clean_html.rb +++ b/lib/docs/filters/vue/clean_html.rb @@ -23,12 +23,23 @@ module Docs # Remove code highlighting css('.line-numbers-wrapper').remove - css('pre').each do |node| - node.parent.name = 'pre' - node.parent['data-language'] = node.parent['class'][/language-(\w+)/, 1] - node.parent['data-language'] = 'javascript' if node.parent['data-language'][/vue/] # unsupported by prism.js - node.parent.remove_attribute 'class' - node.parent.content = node.content.strip + if version == '3' + css('pre').each do |node| + node.parent.name = 'pre' + node.parent['data-language'] = node.parent['class'][/language-(\w+)/, 1] + node.parent['data-language'] = 'javascript' if node.parent['data-language'][/vue/] # unsupported by prism.js + node.parent.remove_attribute 'class' + node.parent.content = node.content.strip + end + else + css('pre').each do |node| + parent = node.ancestors('figure')[0] + parent.name = 'pre' + parent['data-language'] = parent['class'][/(html|js)/, 1] + parent.remove_attribute 'class' + node.css('br').each{ |br| br.replace "\n" } + parent.content = node.content.strip + end end css('.vue-mastery-link').remove