Commits

Luke Plant  committed 02d3535 Merge

Merged bug fix

  • Participants
  • Parent commits 481ea15, 23f548a

Comments (0)

Files changed (2)

File semanticeditor/tests.py

         self.assertEqualClean("<em><ul><li>A test</li></ul></strong>",
                               "<ul><li>A test</li></ul>")
 
+    def test_duplicate_ids(self):
+        self.assertEqualClean('<p id="p_1">test</p><p id="p_1">test 2</p>',
+                              '<p id="p_1">test</p><p>test 2</p>')

File semanticeditor/utils/presentation.py

             if pq(n).is_(blockdef_selector):
                 pull_up(n)
 
+    # remove duplicate 'id' attributes.
+    ids = [n.get('id', None) for n in doc('*[id]')]
+    ids = [i for i in ids if i != "" and i != None]
+    for i in set(ids):
+        for j, node in enumerate(doc('#' + i)):
+            if (j > 0): # skip the first one
+                del n.attrib['id']
+
     for x in ['p + br', 'p:empty']:
         doc(x).remove()