Also simplify item labels, due to XML limitations
This commit is contained in:
@@ -29,7 +29,7 @@ from lxml import etree
|
|||||||
|
|
||||||
from novelwriter.enum import nwItemType, nwItemClass, nwItemLayout
|
from novelwriter.enum import nwItemType, nwItemClass, nwItemLayout
|
||||||
from novelwriter.common import (
|
from novelwriter.common import (
|
||||||
checkInt, isHandle, isItemClass, isItemLayout, isItemType
|
checkInt, isHandle, isItemClass, isItemLayout, isItemType, simplified
|
||||||
)
|
)
|
||||||
from novelwriter.constants import nwLabels, nwLists, trConst
|
from novelwriter.constants import nwLabels, nwLists, trConst
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ class NWItem():
|
|||||||
"""Set the item name.
|
"""Set the item name.
|
||||||
"""
|
"""
|
||||||
if isinstance(theName, str):
|
if isinstance(theName, str):
|
||||||
self._name = theName.strip()
|
self._name = simplified(theName)
|
||||||
else:
|
else:
|
||||||
self._name = ""
|
self._name = ""
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ def testCoreItem_Setters(mockGUI, constData):
|
|||||||
assert theItem.itemName == "A Name"
|
assert theItem.itemName == "A Name"
|
||||||
theItem.setName("\t A Name ")
|
theItem.setName("\t A Name ")
|
||||||
assert theItem.itemName == "A Name"
|
assert theItem.itemName == "A Name"
|
||||||
|
theItem.setName("\t A\t\u2009\u202f\u2002\u2003\u2028\u2029Name ")
|
||||||
|
assert theItem.itemName == "A Name"
|
||||||
theItem.setName(123)
|
theItem.setName(123)
|
||||||
assert theItem.itemName == ""
|
assert theItem.itemName == ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user