Minor fixes and updates (#1026)

* Make the Tokenizer class an abstract class
* Fix error message when opening non-file project items
This commit is contained in:
Veronica Berglyd Olsen
2022-03-20 17:00:29 +01:00
committed by GitHub
parent fbff421de8
commit 6e3262f78e
3 changed files with 23 additions and 13 deletions
+3 -3
View File
@@ -183,9 +183,9 @@ class NWItem():
self.setParent(xItem.attrib.get("parent", None))
self.setOrder(xItem.attrib.get("order", 0))
self.setType(xItem.attrib.get("type", None))
self.setClass(xItem.attrib.get("class", None))
self.setLayout(xItem.attrib.get("layout", None))
self.setType(xItem.attrib.get("type", nwItemType.NO_TYPE))
self.setClass(xItem.attrib.get("class", nwItemClass.NO_CLASS))
self.setLayout(xItem.attrib.get("layout", nwItemLayout.NO_LAYOUT))
for xValue in xItem:
if xValue.tag == "meta":
+7 -2
View File
@@ -1,7 +1,7 @@
"""
novelWriter Text Tokenizer
============================
Splits a piece of novelWriter markdown text into its elements
Split novelWriter plain text into its elements
File History:
Created: 2019-05-05 [0.0.1]
@@ -27,6 +27,7 @@ import re
import logging
import novelwriter
from abc import ABC, abstractmethod
from operator import itemgetter
from functools import partial
@@ -40,7 +41,7 @@ from novelwriter.core.document import NWDoc
logger = logging.getLogger(__name__)
class Tokenizer():
class Tokenizer(ABC):
# In-Text Format
FMT_B_B = 1 # Begin bold
@@ -267,6 +268,10 @@ class Tokenizer():
# Class Methods
##
@abstractmethod
def doConvert(self):
raise NotImplementedError
def addRootHeading(self, theHandle):
"""Add a heading at the start of a new root folder.
"""