Merge pull request #2088 from thewheat/cpp-fix-error-on-fix-code

CPP Fix - prevent source code parent replacement if parent is a list item
pull/2073/head
Simon Legner 1 year ago committed by GitHub
commit 9aac42c989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,7 +58,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,11 +3,13 @@ module Docs
class FixCodeFilter < Filter
def call
css('div > span.source-c', 'div > span.source-cpp').each do |node|
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
css('pre').each do |node|

Loading…
Cancel
Save