Przeglądaj źródła

C/Cpp: improve format of fractions

Enoc 4 lat temu
rodzic
commit
ef449857d5
1 zmienionych plików z 14 dodań i 0 usunięć
  1. 14 0
      lib/docs/filters/cppref/clean_html.rb

+ 14 - 0
lib/docs/filters/cppref/clean_html.rb

@@ -109,6 +109,20 @@ module Docs
           node['src'] = node['src'].sub! %r{http://en.cppreference.com/common/([^"']+?)\.svg}, 'http://upload.cppreference.com/mwiki/\1.svg'
         end
 
+        # temporary solution due lack of mathjax/mathml support
+        css('.t-mfrac').each do |node|
+          fraction = Nokogiri::XML::Node.new('span', doc)
+
+          node.css('td').each do |node|
+            fraction.add_child("<span>#{node.content}</span>")
+          end
+
+          fraction.last_element_child().before("<span>/</span>")
+
+          node.before(fraction)
+          node.remove
+        end
+
         doc
       end
     end