Commits

Luke Plant committed 02fadbe

Changed LayoutDetails to not output 'columns1' for case of single column row.

Comments (0)

Files changed (2)

semanticeditor/tests.py

                 "<div><h1>2</h1></div>" \
               "</div>" \
             "</div>" \
-            "<div class=\"row columns1\">" \
-              "<div class=\"column firstcolumn lastcolumn\">" \
+            "<div class=\"row\">" \
+              "<div>" \
                 "<div><h1>3</h1>" \
                   "<div class=\"row columns3\">" \
                     "<div class=\"column firstcolumn\">" \
                 "</div>" \
               "</div>" \
             "</div>" \
-            "<div class=\"row columns1\">" \
-              "<div class=\"column firstcolumn lastcolumn\">" \
+            "<div class=\"row\">" \
+              "<div>" \
                 "<div><h1>4</h1></div>" \
               "</div>" \
             "</div>"
                                                             '1.1':[NEWROW]})
 
 
+    def test_columns_single_col(self):
+        html = "<h1>1</h1><p>para 1</p><h2>2</h2>"
+        outh = "<div class=\"row\"><div><div><h1>1</h1><div><p>para 1</p></div><div><h2>2</h2></div></div></div></div>"
+        self.assertEqual(outh, format_html(html, {'1':[NEWROW]}))
+
+
 class TestElementTreeUtils(TestCase):
     def test_get_parent(self):
         """

semanticeditor/utils/presentation.py

 
 ### Layout CSS class names ###
 
-# This is designed to be user supplyable if necessary
+# This is designed to be user supply-able if necessary
 
 class LayoutDetails(object):
     ROW_CLASS = "row"
         Returns a list of CSS classes to be used for a row
         containing column_count columns
         """
-        return [self.ROW_CLASS, "columns%d" % column_count]
+        retval = [self.ROW_CLASS]
+        if column_count > 1:
+            retval.append("columns%d" % column_count)
+        return retval
 
     def column_classes(self, column_num, column_count):
         """
         Returns the CSS class to be used for a column
         which is number column_num out of column_count.
         """
+        if column_count == 1:
+            # No classes
+            return []
         retval = [self.COLUMN_CLASS]
         if column_num == 1:
             retval.append("firstcolumn")
     # Add the row
     total_columns = len(columns)
     newrow = wrap_elements_in_tag(parent, start_idx, stop_idx, 'div')
-    newrow.set('class', ' '.join(layout_strategy.row_classes(total_columns)))
+    classes = ' '.join(layout_strategy.row_classes(total_columns))
+    if classes:
+        newrow.set('class', classes)
 
     # Add the columns
     if total_columns > MAXCOLS:
             # last dummy entry
             continue
         newcol = wrap_elements_in_tag(newrow, idx, columns[i - 1][0], 'div')
-        newcol.set('class', ' '.join(layout_strategy.column_classes(total_columns - i + 1, total_columns)))
+        classes = ' '.join(layout_strategy.column_classes(total_columns - i + 1, total_columns))
+        if classes:
+            newcol.set('class', classes)
 
 def preview_html(html, pres):
     root, structure, section_nodes = format_html(html, pres, return_tree=True)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.