Skip to content

Commit

Permalink
Merge pull request #2088 from thewheat/cpp-fix-error-on-fix-code
Browse files Browse the repository at this point in the history
CPP Fix - prevent source code parent replacement if parent is a list item
  • Loading branch information
simon04 authored Jan 5, 2024
2 parents 8502d8f + 4bdbbcd commit 9aac42c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/docs/filters/cppref/clean_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def call
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')
Expand Down
10 changes: 6 additions & 4 deletions lib/docs/filters/cppref/fix_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ class Cppref
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
Expand Down

0 comments on commit 9aac42c

Please sign in to comment.