Showing the changes to lib/docs/filters/cppref/fix_code.rb (1 of 9 files). Show all
Unified · Split
| @@ -0,0 +1,21 @@ | ||
| 1 | +module Docs | |
| 2 | + class Cppref | |
| 3 | + class FixCodeFilter < Filter | |
| 4 | + def call | |
| 5 | + css('div > span.source-c', 'div > span.source-cpp').each do |node| | |
| 6 | + node.inner_html = node.inner_html.gsub(/<br>\n?/, "\n").gsub("\n</p>\n", "</p>\n") | |
| 7 | + node.parent.name = 'pre' | |
| 8 | + node.parent['class'] = node['class'] | |
| 9 | + node.parent.content = node.content | |
| 10 | + end | |
| 11 | + | |
| 12 | + nbsp = Nokogiri::HTML(' ').text | |
| 13 | + css('pre').each do |node| | |
| 14 | + node.content = node.content.gsub(nbsp, ' ') | |
| 15 | + end | |
| 16 | + | |
| 17 | + doc | |
| 18 | + end | |
| 19 | + end | |
| 20 | + end | |
| 21 | +end | |