CPP Fix - prevent source code parent replacement if parent is a list item

pull/2088/head
Tim Lim 1 year ago
parent 887c879e0f
commit 4bdbbcd25a

@ -57,7 +57,7 @@ module Docs
node.content = ' ' if node.content.empty?
end
css('tt', 'span > span.source-cpp', 'span.t-c', 'span.t-lc', 'span.t-dsc-see-tt').each do |node|
css('tt', 'span > span.source-cpp', 'span.t-c', 'span.t-lc', 'span.t-dsc-see-tt', 'div.t-li1 > span.source-cpp', 'div.t-li2 > span.source-cpp', 'div.t-li3 > span.source-cpp').each do |node|
node.name = 'code'
node.remove_attribute('class')
node.content = node.content unless node.at_css('a')

@ -3,10 +3,12 @@ module Docs
class FixCodeFilter < Filter
def call
css('div > span.source-c', 'div > span.source-cpp').each do |node|
node.inner_html = node.inner_html.gsub(/<br>\n?/, "\n").gsub("\n</p>\n", "</p>\n")
node.parent.name = 'pre'
node.parent['class'] = node['class']
node.parent.content = node.content
if (node.parent.classes||[]).none?{|className| ['t-li1','t-li2','t-li3'].include?(className) }
node.inner_html = node.inner_html.gsub(/<br>\n?/, "\n").gsub("\n</p>\n", "</p>\n")
node.parent.name = 'pre'
node.parent['class'] = node['class']
node.parent.content = node.content
end
end
nbsp = Nokogiri::HTML('&nbsp;').text

Loading…
Cancel
Save