public
Description: Yet Another Planet Refactoring
Homepage: http://intertwingly.net/blog/2007/12/19/Yet-Another-Planet-Refactoring
Clone URL: git://github.com/rubys/mars.git
Search Repo:
cull empty formatting elements.  They can cause FF & Konq to nest 
badly.
For instance, <i/> in an entry causes everything after it to 
italicized,
including all the text in following entries.
Scott Bronson (author)
Mon Mar 31 23:29:15 -0700 2008
commit  775bc2a397c7812ae67b9979f288c3c835aab059
tree    b847bf45fa3471cc91ecd89b2524fceb081f6f69
parent  567e2f3f459d446f0530bbd4c8acb00dde378420
...
112
113
114
 
 
 
 
 
 
 
 
 
 
 
115
116
117
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
0
@@ -112,6 +112,17 @@
0
   include HTML5::HTMLSanitizeModule
0
   @sanitizer = HTML5::HTMLSanitizer.new ''
0
   def Planet.sanitize node, fido
0
+ # cull empty formatting elements. They can cause FF & Konq to nest badly.
0
+ # For instance, <i/> causes everything after it to italicized, including other entries.
0
+ if node.elements.size == 0 && node.text == nil
0
+ if %w{abbr acronym b big cite code del dfn em i ins kbd s
0
+ samp small strike strong sub sup tt u var}.include? node.name
0
+ # If the node has no children and no text, it can only cause trouble.
0
+ node.remove
0
+ return
0
+ end
0
+ end
0
+
0
     node.elements.each {|child| sanitize child, fido}
0
 
0
     if node.namespace == 'http://www.w3.org/1999/xhtml'

Comments

    No one has commented yet.