Commits

Luke Plant  committed 67adf93

Used regexps for more robust matching

  • Participants
  • Parent commits 82579db

Comments (0)

Files changed (1)

File semanticeditor/utils/presentation.py

 from elementtree import ElementTree as ET
 from semanticeditor.utils.etree import cleanup, flatten, get_parent, get_index, wrap_elements_in_tag
 from xml.parsers import expat
+import re
 
 ### Errors ###
 
 
 MAXCOLS = 4
 COLUMNCLASS = 'col'
-ROWCLASSPREFIX = 'row'
-ROWCLASS = ROWCLASSPREFIX + '%dcol'
+ROWCLASSRE = re.compile('^row(\d+)col$')
+ROWCLASS = 'row%dcol'
 
 ### Parsing ###
 
                 pres[name].add(NEWCOL)
             gp = get_parent(root, p)
             if gp is not None and gp.tag == 'div':
-                if any(c.startswith(ROWCLASSPREFIX) for c in _get_classes_for_node(gp)) \
+                if any(ROWCLASSRE.match(c) is not None for c in _get_classes_for_node(gp)) \
                         and get_index(gp, p) == 0:
                     pres[name].add(NEWROW)
                     pres[name].discard(NEWCOL) # not technically necessary