# File lib/html5/treebuilders/base.rb, line 141 def reconstructActiveFormattingElements # Within this algorithm the order of steps described in the # specification is not quite the same as the order of steps in the # code. It should still do the same though. # Step 1: stop the algorithm when there's nothing to do. return if @activeFormattingElements.empty? # Step 2 and step 3: we start with the last element. So i is -1. i = -1 entry = @activeFormattingElements[i] return if entry == Marker or @open_elements.include?(entry) # Step 6 until entry == Marker or @open_elements.include?(entry) # Step 5: let entry be one earlier in the list. i -= 1 begin entry = @activeFormattingElements[i] rescue # Step 4: at this point we need to jump to step 8. By not doing # i += 1 which is also done in step 7 we achieve that. break end end while true # Step 7 i += 1 # Step 8 clone = @activeFormattingElements[i].cloneNode # Step 9 element = insert_element(clone.name, clone.attributes) # Step 10 @activeFormattingElements[i] = element # Step 11 break if element == @activeFormattingElements[-1] end end