Refactor core and base classes (#931)
* Improve the NWIndex class * Improve the NWItem and NWDoc classes * Make some optimisations in projects and update tests * Minor changes to string formatting in main source file * Add some more protection to core classes * Make all converter class attributes private
This commit is contained in:
committed by
GitHub
parent
2f75d88694
commit
5e2ab4f612
@@ -44,6 +44,7 @@ def testCoreDocument_LoadSave(monkeypatch, mockGUI, nwMinimal):
|
||||
|
||||
# Not a valid handle
|
||||
theDoc = NWDoc(theProject, "stuff")
|
||||
assert bool(theDoc) is False
|
||||
assert theDoc.readDocument() is None
|
||||
|
||||
# Non-existent handle
|
||||
@@ -67,6 +68,8 @@ def testCoreDocument_LoadSave(monkeypatch, mockGUI, nwMinimal):
|
||||
assert nHandle is not None
|
||||
xHandle = theProject.newFile("New File", nwItemClass.NOVEL, nHandle)
|
||||
theDoc = NWDoc(theProject, xHandle)
|
||||
assert bool(theDoc) is True
|
||||
assert repr(theDoc) == f"<NWDoc handle={xHandle}>"
|
||||
assert theDoc.readDocument() == ""
|
||||
|
||||
# Write Document
|
||||
|
||||
@@ -219,6 +219,9 @@ def testCoreIndex_CheckThese(nwMinimal, mockGUI):
|
||||
assert theIndex.notesChangedSince(0) is True
|
||||
assert theIndex.indexChangedSince(0) is True
|
||||
|
||||
assert theIndex.getHandleHeaderLevel(cHandle) == "H1"
|
||||
assert theIndex.getHandleHeaderLevel(nHandle) == "H1"
|
||||
|
||||
# Zero Items
|
||||
assert theIndex.checkThese([], cItem) == []
|
||||
|
||||
|
||||
@@ -48,36 +48,39 @@ def testCoreProject_NewMinimal(fncDir, outDir, refDir, mockGUI):
|
||||
theProject.projTree.setSeed(42)
|
||||
|
||||
# Setting no data should fail
|
||||
assert not theProject.newProject({})
|
||||
assert theProject.newProject({}) is False
|
||||
|
||||
# Wrong type should also fail
|
||||
assert theProject.newProject("stuff") is False
|
||||
|
||||
# Try again with a proper path
|
||||
assert theProject.newProject({"projPath": fncDir})
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.newProject({"projPath": fncDir}) is True
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
|
||||
# Creating the project once more should fail
|
||||
assert not theProject.newProject({"projPath": fncDir})
|
||||
assert theProject.newProject({"projPath": fncDir}) is False
|
||||
|
||||
# Check the new project
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
||||
|
||||
# Open again
|
||||
assert theProject.openProject(projFile)
|
||||
assert theProject.openProject(projFile) is True
|
||||
|
||||
# Save and close
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
||||
assert not theProject.projChanged
|
||||
assert theProject.projChanged is False
|
||||
|
||||
# Open a second time
|
||||
assert theProject.openProject(projFile)
|
||||
assert not theProject.openProject(projFile)
|
||||
assert theProject.openProject(projFile, overrideLock=True)
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.openProject(projFile) is True
|
||||
assert theProject.openProject(projFile) is False
|
||||
assert theProject.openProject(projFile, overrideLock=True) is True
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
||||
|
||||
@@ -116,9 +119,9 @@ def testCoreProject_NewCustomA(fncDir, outDir, refDir, mockGUI):
|
||||
theProject = NWProject(mockGUI)
|
||||
theProject.projTree.setSeed(42)
|
||||
|
||||
assert theProject.newProject(projData)
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.newProject(projData) is True
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
||||
@@ -158,9 +161,9 @@ def testCoreProject_NewCustomB(fncDir, outDir, refDir, mockGUI):
|
||||
theProject = NWProject(mockGUI)
|
||||
theProject.projTree.setSeed(42)
|
||||
|
||||
assert theProject.newProject(projData)
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.newProject(projData) is True
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
||||
@@ -207,11 +210,11 @@ def testCoreProject_NewSampleA(fncDir, tmpConf, mockGUI, tmpDir):
|
||||
srcDoc = os.path.join(srcSample, "content", docFile)
|
||||
zipObj.write(srcDoc, "content/"+docFile)
|
||||
|
||||
assert theProject.newProject(projData)
|
||||
assert theProject.openProject(fncDir)
|
||||
assert theProject.newProject(projData) is True
|
||||
assert theProject.openProject(fncDir) is True
|
||||
assert theProject.projName == "Sample Project"
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
os.unlink(dstSample)
|
||||
|
||||
# END Test testCoreProject_NewSampleA
|
||||
@@ -242,11 +245,11 @@ def testCoreProject_NewSampleB(monkeypatch, fncDir, tmpConf, mockGUI, tmpDir):
|
||||
assert not theProject.newProject(projData)
|
||||
|
||||
monkeypatch.setattr(nwFiles, "PROJ_FILE", "nwProject.nwx")
|
||||
assert theProject.newProject(projData)
|
||||
assert theProject.openProject(fncDir)
|
||||
assert theProject.newProject(projData) is True
|
||||
assert theProject.openProject(fncDir) is True
|
||||
assert theProject.projName == "Sample Project"
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
|
||||
# Misdirect the appRoot path so neither is possible
|
||||
tmpConf.appRoot = tmpDir
|
||||
@@ -266,11 +269,11 @@ def testCoreProject_NewRoot(fncDir, outDir, refDir, mockGUI):
|
||||
theProject = NWProject(mockGUI)
|
||||
theProject.projTree.setSeed(42)
|
||||
|
||||
assert theProject.newProject({"projPath": fncDir})
|
||||
assert theProject.setProjectPath(fncDir)
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.openProject(projFile)
|
||||
assert theProject.newProject({"projPath": fncDir}) is True
|
||||
assert theProject.setProjectPath(fncDir) is True
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
assert theProject.openProject(projFile) is True
|
||||
|
||||
assert isinstance(theProject.newRoot("Novel", nwItemClass.NOVEL), type(None))
|
||||
assert isinstance(theProject.newRoot("Plot", nwItemClass.PLOT), type(None))
|
||||
@@ -281,13 +284,13 @@ def testCoreProject_NewRoot(fncDir, outDir, refDir, mockGUI):
|
||||
assert isinstance(theProject.newRoot("Custom1", nwItemClass.CUSTOM), str)
|
||||
assert isinstance(theProject.newRoot("Custom2", nwItemClass.CUSTOM), str)
|
||||
|
||||
assert theProject.projChanged
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.projChanged is True
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
||||
assert not theProject.projChanged
|
||||
assert theProject.projChanged is False
|
||||
|
||||
# END Test testCoreProject_NewRoot
|
||||
|
||||
@@ -303,21 +306,21 @@ def testCoreProject_NewFile(fncDir, outDir, refDir, mockGUI):
|
||||
theProject = NWProject(mockGUI)
|
||||
theProject.projTree.setSeed(42)
|
||||
|
||||
assert theProject.newProject({"projPath": fncDir})
|
||||
assert theProject.setProjectPath(fncDir)
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.openProject(projFile)
|
||||
assert theProject.newProject({"projPath": fncDir}) is True
|
||||
assert theProject.setProjectPath(fncDir) is True
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
assert theProject.openProject(projFile) is True
|
||||
|
||||
assert isinstance(theProject.newFile("Hello", nwItemClass.NOVEL, "31489056e0916"), str)
|
||||
assert isinstance(theProject.newFile("Jane", nwItemClass.CHARACTER, "71ee45a3c0db9"), str)
|
||||
assert theProject.projChanged
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
assert theProject.saveProject() is True
|
||||
assert theProject.closeProject() is True
|
||||
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
||||
assert not theProject.projChanged
|
||||
assert theProject.projChanged is False
|
||||
|
||||
# END Test testCoreProject_NewFile
|
||||
|
||||
@@ -466,6 +469,7 @@ def testCoreProject_Save(monkeypatch, nwMinimal, mockGUI, refDir):
|
||||
"""
|
||||
theProject = NWProject(mockGUI)
|
||||
testFile = os.path.join(nwMinimal, "nwProject.nwx")
|
||||
backFile = os.path.join(nwMinimal, "nwProject.bak")
|
||||
compFile = os.path.join(refDir, os.path.pardir, "minimal", "nwProject.nwx")
|
||||
|
||||
# Nothing to save
|
||||
@@ -476,7 +480,7 @@ def testCoreProject_Save(monkeypatch, nwMinimal, mockGUI, refDir):
|
||||
|
||||
# Fail on folder structure check
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr("os.path.isdir", lambda *args: False)
|
||||
mp.setattr("os.path.isdir", lambda *a: False)
|
||||
assert theProject.saveProject() is False
|
||||
|
||||
# Fail on open file
|
||||
@@ -484,6 +488,12 @@ def testCoreProject_Save(monkeypatch, nwMinimal, mockGUI, refDir):
|
||||
mp.setattr("builtins.open", causeOSError)
|
||||
assert theProject.saveProject() is False
|
||||
|
||||
# Fail on creating .bak file
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr("os.replace", causeOSError)
|
||||
assert theProject.saveProject() is False
|
||||
assert os.path.isfile(backFile) is False
|
||||
|
||||
# Successful save
|
||||
saveCount = theProject.saveCount
|
||||
autoCount = theProject.autoCount
|
||||
@@ -492,6 +502,9 @@ def testCoreProject_Save(monkeypatch, nwMinimal, mockGUI, refDir):
|
||||
assert theProject.autoCount == autoCount
|
||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8, 9])
|
||||
|
||||
# Check that a second save creates a .bak file
|
||||
assert os.path.isfile(backFile) is True
|
||||
|
||||
# Successful autosave
|
||||
saveCount = theProject.saveCount
|
||||
autoCount = theProject.autoCount
|
||||
|
||||
@@ -38,12 +38,12 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
# Novel Files Headers
|
||||
# ===================
|
||||
|
||||
theHtml.isNovel = True
|
||||
theHtml.isNote = False
|
||||
theHtml.isFirst = True
|
||||
theHtml._isNovel = True
|
||||
theHtml._isNote = False
|
||||
theHtml._isFirst = True
|
||||
|
||||
# Header 1
|
||||
theHtml.theText = "# Partition\n"
|
||||
theHtml._theText = "# Partition\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -51,7 +51,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Header 2
|
||||
theHtml.theText = "## Chapter Title\n"
|
||||
theHtml._theText = "## Chapter Title\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -59,19 +59,19 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Header 3
|
||||
theHtml.theText = "### Scene Title\n"
|
||||
theHtml._theText = "### Scene Title\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h2>Scene Title</h2>\n"
|
||||
|
||||
# Header 4
|
||||
theHtml.theText = "#### Section Title\n"
|
||||
theHtml._theText = "#### Section Title\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h3>Section Title</h3>\n"
|
||||
|
||||
# Title
|
||||
theHtml.theText = "#! Title\n"
|
||||
theHtml._theText = "#! Title\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -79,7 +79,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Unnumbered
|
||||
theHtml.theText = "##! Prologue\n"
|
||||
theHtml._theText = "##! Prologue\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h1 style='page-break-before: always;'>Prologue</h1>\n"
|
||||
@@ -87,37 +87,37 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
# Note Files Headers
|
||||
# ==================
|
||||
|
||||
theHtml.isNovel = False
|
||||
theHtml.isNote = True
|
||||
theHtml.isFirst = True
|
||||
theHtml._isNovel = False
|
||||
theHtml._isNote = True
|
||||
theHtml._isFirst = True
|
||||
theHtml.setLinkHeaders(True)
|
||||
|
||||
# Header 1
|
||||
theHtml.theText = "# Heading One\n"
|
||||
theHtml._theText = "# Heading One\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h1><a name='T000001'></a>Heading One</h1>\n"
|
||||
|
||||
# Header 2
|
||||
theHtml.theText = "## Heading Two\n"
|
||||
theHtml._theText = "## Heading Two\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h2><a name='T000001'></a>Heading Two</h2>\n"
|
||||
|
||||
# Header 3
|
||||
theHtml.theText = "### Heading Three\n"
|
||||
theHtml._theText = "### Heading Three\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h3><a name='T000001'></a>Heading Three</h3>\n"
|
||||
|
||||
# Header 4
|
||||
theHtml.theText = "#### Heading Four\n"
|
||||
theHtml._theText = "#### Heading Four\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h4><a name='T000001'></a>Heading Four</h4>\n"
|
||||
|
||||
# Title
|
||||
theHtml.theText = "#! Heading One\n"
|
||||
theHtml._theText = "#! Heading One\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -125,7 +125,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Unnumbered
|
||||
theHtml.theText = "##! Heading Two\n"
|
||||
theHtml._theText = "##! Heading Two\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h2><a name='T000001'></a>Heading Two</h2>\n"
|
||||
@@ -134,7 +134,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Text
|
||||
theHtml.theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theHtml._theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -143,7 +143,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Text w/Hard Break
|
||||
theHtml.theText = "Line one \nLine two \nLine three\n"
|
||||
theHtml._theText = "Line one \nLine two \nLine three\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -151,13 +151,13 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Synopsis
|
||||
theHtml.theText = "%synopsis: The synopsis ...\n"
|
||||
theHtml._theText = "%synopsis: The synopsis ...\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == ""
|
||||
|
||||
theHtml.setSynopsis(True)
|
||||
theHtml.theText = "%synopsis: The synopsis ...\n"
|
||||
theHtml._theText = "%synopsis: The synopsis ...\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -165,13 +165,13 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Comment
|
||||
theHtml.theText = "% A comment ...\n"
|
||||
theHtml._theText = "% A comment ...\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == ""
|
||||
|
||||
theHtml.setComments(True)
|
||||
theHtml.theText = "% A comment ...\n"
|
||||
theHtml._theText = "% A comment ...\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -179,13 +179,13 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Keywords
|
||||
theHtml.theText = "@char: Bod, Jane\n"
|
||||
theHtml._theText = "@char: Bod, Jane\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == ""
|
||||
|
||||
theHtml.setKeywords(True)
|
||||
theHtml.theText = "@char: Bod, Jane\n"
|
||||
theHtml._theText = "@char: Bod, Jane\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -195,7 +195,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
|
||||
# Multiple Keywords
|
||||
theHtml.setKeywords(True)
|
||||
theHtml.theText = "## Chapter\n\n@pov: Bod\n@plot: Main\n@location: Europe\n\n"
|
||||
theHtml._theText = "## Chapter\n\n@pov: Bod\n@plot: Main\n@location: Europe\n\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -218,7 +218,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
theHtml.setPreview(True, True)
|
||||
|
||||
# Text (HTML4)
|
||||
theHtml.theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theHtml._theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -238,15 +238,15 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
mockGUI.theIndex = NWIndex(theProject)
|
||||
theHtml = ToHtml(theProject)
|
||||
|
||||
theHtml.isNovel = True
|
||||
theHtml.isNote = False
|
||||
theHtml._isNovel = True
|
||||
theHtml._isNote = False
|
||||
theHtml.setLinkHeaders(True)
|
||||
|
||||
# Special Titles
|
||||
# ==============
|
||||
|
||||
# Title
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_TITLE, 1, "A Title", None, theHtml.A_PBB | theHtml.A_CENTRE),
|
||||
(theHtml.T_EMPTY, 1, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -257,7 +257,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Unnumbered
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_UNNUM, 1, "Prologue", None, theHtml.A_PBB),
|
||||
(theHtml.T_EMPTY, 1, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -271,7 +271,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Separator
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_SEP, 1, "* * *", None, theHtml.A_CENTRE),
|
||||
(theHtml.T_EMPTY, 1, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -279,7 +279,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
assert theHtml.theResult == "<p class='sep' style='text-align: center;'>* * *</p>\n"
|
||||
|
||||
# Skip
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_SKIP, 1, "", None, theHtml.A_NONE),
|
||||
(theHtml.T_EMPTY, 1, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -293,7 +293,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
|
||||
# Align Left
|
||||
theHtml.setStyles(False)
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_LEFT),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -304,7 +304,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
theHtml.setStyles(True)
|
||||
|
||||
# Align Left
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_LEFT),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -313,7 +313,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Align Right
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_RIGHT),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -322,7 +322,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Align Centre
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_CENTRE),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -331,7 +331,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Align Justify
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_JUSTIFY),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -343,7 +343,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Page Break Always
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_PBB | theHtml.A_PBA),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -356,7 +356,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
# ======
|
||||
|
||||
# Indent Left
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_TEXT, 1, "Some text ...", [], theHtml.A_IND_L),
|
||||
(theHtml.T_EMPTY, 2, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -366,7 +366,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Indent Right
|
||||
theHtml.theTokens = [
|
||||
theHtml._theTokens = [
|
||||
(theHtml.T_TEXT, 1, "Some text ...", [], theHtml.A_IND_R),
|
||||
(theHtml.T_EMPTY, 2, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -384,33 +384,33 @@ def testCoreToHtml_SpecialCases(mockGUI):
|
||||
"""
|
||||
theProject = NWProject(mockGUI)
|
||||
theHtml = ToHtml(theProject)
|
||||
theHtml.isNovel = True
|
||||
theHtml._isNovel = True
|
||||
|
||||
# Greater/Lesser than symbols
|
||||
# ===========================
|
||||
|
||||
theHtml.theText = "Text with > and < with some **bold text** in it.\n"
|
||||
theHtml._theText = "Text with > and < with some **bold text** in it.\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
"<p>Text with > and < with some <strong>bold text</strong> in it.</p>\n"
|
||||
)
|
||||
|
||||
theHtml.theText = "Text with some <**bold text**> in it.\n"
|
||||
theHtml._theText = "Text with some <**bold text**> in it.\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
"<p>Text with some <<strong>bold text</strong>> in it.</p>\n"
|
||||
)
|
||||
|
||||
theHtml.theText = "Let's > be > _difficult **shall** > we_?\n"
|
||||
theHtml._theText = "Let's > be > _difficult **shall** > we_?\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
"<p>Let's > be > <em>difficult <strong>shall</strong> > we</em>?</p>\n"
|
||||
)
|
||||
|
||||
theHtml.theText = "Test > text _<**bold**>_ and more.\n"
|
||||
theHtml._theText = "Test > text _<**bold**>_ and more.\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -426,7 +426,7 @@ def testCoreToHtml_Complex(mockGUI, fncDir):
|
||||
"""
|
||||
theProject = NWProject(mockGUI)
|
||||
theHtml = ToHtml(theProject)
|
||||
theHtml.isNovel = True
|
||||
theHtml._isNovel = True
|
||||
|
||||
# Build Project
|
||||
# =============
|
||||
@@ -472,7 +472,7 @@ def testCoreToHtml_Complex(mockGUI, fncDir):
|
||||
]
|
||||
|
||||
for i in range(len(docText)):
|
||||
theHtml.theText = docText[i]
|
||||
theHtml._theText = docText[i]
|
||||
theHtml.doPreProcessing()
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
@@ -526,7 +526,7 @@ def testCoreToHtml_Methods(mockGUI):
|
||||
|
||||
# Auto-Replace, keep Unicode
|
||||
docText = "Text with <brackets> & short–dash, long—dash …\n"
|
||||
theHtml.theText = docText
|
||||
theHtml._theText = docText
|
||||
theHtml.setReplaceUnicode(False)
|
||||
theHtml.doPreProcessing()
|
||||
theHtml.tokenizeText()
|
||||
@@ -537,7 +537,7 @@ def testCoreToHtml_Methods(mockGUI):
|
||||
|
||||
# Auto-Replace, replace Unicode
|
||||
docText = "Text with <brackets> & short–dash, long—dash …\n"
|
||||
theHtml.theText = docText
|
||||
theHtml._theText = docText
|
||||
theHtml.setReplaceUnicode(True)
|
||||
theHtml.doPreProcessing()
|
||||
theHtml.tokenizeText()
|
||||
@@ -548,7 +548,7 @@ def testCoreToHtml_Methods(mockGUI):
|
||||
|
||||
# With Preview
|
||||
theHtml.setPreview(True, True)
|
||||
theHtml.theText = docText
|
||||
theHtml._theText = docText
|
||||
theHtml.doPreProcessing()
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,42 +38,42 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
# Headers
|
||||
# =======
|
||||
|
||||
theMD.isNovel = True
|
||||
theMD.isNote = False
|
||||
theMD.isFirst = True
|
||||
theMD._isNovel = True
|
||||
theMD._isNote = False
|
||||
theMD._isFirst = True
|
||||
|
||||
# Header 1
|
||||
theMD.theText = "# Partition\n"
|
||||
theMD._theText = "# Partition\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "# Partition\n\n"
|
||||
|
||||
# Header 2
|
||||
theMD.theText = "## Chapter Title\n"
|
||||
theMD._theText = "## Chapter Title\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "## Chapter Title\n\n"
|
||||
|
||||
# Header 3
|
||||
theMD.theText = "### Scene Title\n"
|
||||
theMD._theText = "### Scene Title\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "### Scene Title\n\n"
|
||||
|
||||
# Header 4
|
||||
theMD.theText = "#### Section Title\n"
|
||||
theMD._theText = "#### Section Title\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "#### Section Title\n\n"
|
||||
|
||||
# Title
|
||||
theMD.theText = "#! Title\n"
|
||||
theMD._theText = "#! Title\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "# Title\n\n"
|
||||
|
||||
# Unnumbered
|
||||
theMD.theText = "##! Prologue\n"
|
||||
theMD._theText = "##! Prologue\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "## Prologue\n\n"
|
||||
@@ -83,7 +83,7 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
|
||||
# Text for GitHub Markdown
|
||||
theMD.setGitHubMarkdown()
|
||||
theMD.theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theMD._theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == (
|
||||
@@ -92,7 +92,7 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
|
||||
# Text for Standard Markdown
|
||||
theMD.setStandardMarkdown()
|
||||
theMD.theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theMD._theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == (
|
||||
@@ -100,50 +100,50 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Text w/Hard Break
|
||||
theMD.theText = "Line one \nLine two \nLine three\n"
|
||||
theMD._theText = "Line one \nLine two \nLine three\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "Line one \nLine two \nLine three\n\n"
|
||||
|
||||
# Synopsis
|
||||
theMD.theText = "%synopsis: The synopsis ...\n"
|
||||
theMD._theText = "%synopsis: The synopsis ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == ""
|
||||
|
||||
theMD.setSynopsis(True)
|
||||
theMD.theText = "%synopsis: The synopsis ...\n"
|
||||
theMD._theText = "%synopsis: The synopsis ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "**Synopsis:** The synopsis ...\n\n"
|
||||
|
||||
# Comment
|
||||
theMD.theText = "% A comment ...\n"
|
||||
theMD._theText = "% A comment ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == ""
|
||||
|
||||
theMD.setComments(True)
|
||||
theMD.theText = "% A comment ...\n"
|
||||
theMD._theText = "% A comment ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "**Comment:** A comment ...\n\n"
|
||||
|
||||
# Keywords
|
||||
theMD.theText = "@char: Bod, Jane\n"
|
||||
theMD._theText = "@char: Bod, Jane\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == ""
|
||||
|
||||
theMD.setKeywords(True)
|
||||
theMD.theText = "@char: Bod, Jane\n"
|
||||
theMD._theText = "@char: Bod, Jane\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "**Characters:** Bod, Jane\n\n"
|
||||
|
||||
# Multiple Keywords
|
||||
theMD.setKeywords(True)
|
||||
theMD.theText = "## Chapter\n\n@pov: Bod\n@plot: Main\n@location: Europe\n\n"
|
||||
theMD._theText = "## Chapter\n\n@pov: Bod\n@plot: Main\n@location: Europe\n\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == (
|
||||
@@ -164,14 +164,14 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
|
||||
mockGUI.theIndex = NWIndex(theProject)
|
||||
theMD = ToMarkdown(theProject)
|
||||
|
||||
theMD.isNovel = True
|
||||
theMD.isNote = False
|
||||
theMD._isNovel = True
|
||||
theMD._isNote = False
|
||||
|
||||
# Special Titles
|
||||
# ==============
|
||||
|
||||
# Title
|
||||
theMD.theTokens = [
|
||||
theMD._theTokens = [
|
||||
(theMD.T_TITLE, 1, "A Title", None, theMD.A_PBB | theMD.A_CENTRE),
|
||||
(theMD.T_EMPTY, 1, "", None, theMD.A_NONE),
|
||||
]
|
||||
@@ -179,7 +179,7 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
|
||||
assert theMD.theResult == "# A Title\n\n"
|
||||
|
||||
# Unnumbered
|
||||
theMD.theTokens = [
|
||||
theMD._theTokens = [
|
||||
(theMD.T_UNNUM, 1, "Prologue", None, theMD.A_PBB),
|
||||
(theMD.T_EMPTY, 1, "", None, theMD.A_NONE),
|
||||
]
|
||||
@@ -190,7 +190,7 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Separator
|
||||
theMD.theTokens = [
|
||||
theMD._theTokens = [
|
||||
(theMD.T_SEP, 1, "* * *", None, theMD.A_CENTRE),
|
||||
(theMD.T_EMPTY, 1, "", None, theMD.A_NONE),
|
||||
]
|
||||
@@ -198,7 +198,7 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
|
||||
assert theMD.theResult == "* * *\n\n"
|
||||
|
||||
# Skip
|
||||
theMD.theTokens = [
|
||||
theMD._theTokens = [
|
||||
(theMD.T_SKIP, 1, "", None, theMD.A_NONE),
|
||||
(theMD.T_EMPTY, 1, "", None, theMD.A_NONE),
|
||||
]
|
||||
@@ -214,7 +214,7 @@ def testCoreToMarkdown_Complex(mockGUI, fncDir):
|
||||
"""
|
||||
theProject = NWProject(mockGUI)
|
||||
theMD = ToMarkdown(theProject)
|
||||
theMD.isNovel = True
|
||||
theMD._isNovel = True
|
||||
|
||||
# Build Project
|
||||
# =============
|
||||
@@ -239,7 +239,7 @@ def testCoreToMarkdown_Complex(mockGUI, fncDir):
|
||||
]
|
||||
|
||||
for i in range(len(docText)):
|
||||
theMD.theText = docText[i]
|
||||
theMD._theText = docText[i]
|
||||
theMD.doPreProcessing()
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
|
||||
@@ -236,7 +236,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
mockGUI.theIndex = NWIndex(theProject)
|
||||
theDoc = ToOdt(theProject, isFlat=True)
|
||||
|
||||
theDoc.isNovel = True
|
||||
theDoc._isNovel = True
|
||||
|
||||
def getStyle(styleName):
|
||||
for aSet in theDoc._autoPara.values():
|
||||
@@ -248,7 +248,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
# =======
|
||||
|
||||
# Header 1
|
||||
theDoc.theText = "# Title\n"
|
||||
theDoc._theText = "# Title\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -261,7 +261,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Header 2
|
||||
theDoc.theText = "## Chapter\n"
|
||||
theDoc._theText = "## Chapter\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -274,7 +274,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Header 3
|
||||
theDoc.theText = "### Scene\n"
|
||||
theDoc._theText = "### Scene\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -287,7 +287,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Header 4
|
||||
theDoc.theText = "#### Section\n"
|
||||
theDoc._theText = "#### Section\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -300,7 +300,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Title
|
||||
theDoc.theText = "#! Title\n"
|
||||
theDoc._theText = "#! Title\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -313,7 +313,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Unnumbered chapter
|
||||
theDoc.theText = "##! Prologue\n"
|
||||
theDoc._theText = "##! Prologue\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -329,7 +329,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Nested Text
|
||||
theDoc.theText = "Some ~~nested **bold** and _italics_ text~~ text."
|
||||
theDoc._theText = "Some ~~nested **bold** and _italics_ text~~ text."
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -347,7 +347,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Hard Break
|
||||
theDoc.theText = "Some text.\nNext line\n"
|
||||
theDoc._theText = "Some text.\nNext line\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -360,7 +360,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Tab
|
||||
theDoc.theText = "\tItem 1\tItem 2\n"
|
||||
theDoc._theText = "\tItem 1\tItem 2\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -373,7 +373,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Tab in Format
|
||||
theDoc.theText = "Some **bold\ttext**"
|
||||
theDoc._theText = "Some **bold\ttext**"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -387,7 +387,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Multiple Spaces
|
||||
theDoc.theText = (
|
||||
theDoc._theText = (
|
||||
"### Scene\n\n"
|
||||
"Hello World\n\n"
|
||||
"Hello World\n\n"
|
||||
@@ -408,7 +408,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Synopsis, Comment, Keywords
|
||||
theDoc.theText = (
|
||||
theDoc._theText = (
|
||||
"### Scene\n\n"
|
||||
"@pov: Jane\n\n"
|
||||
"% synopsis: So it begins\n\n"
|
||||
@@ -435,7 +435,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Scene Separator
|
||||
theDoc.theText = "### Scene One\n\nText\n\n### Scene Two\n\nText"
|
||||
theDoc._theText = "### Scene One\n\nText\n\n### Scene Two\n\nText"
|
||||
theDoc.setSceneFormat("* * *", False)
|
||||
theDoc.tokenizeText()
|
||||
theDoc.doHeaders()
|
||||
@@ -453,7 +453,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Scene Break
|
||||
theDoc.theText = "### Scene One\n\nText\n\n### Scene Two\n\nText"
|
||||
theDoc._theText = "### Scene One\n\nText\n\n### Scene Two\n\nText"
|
||||
theDoc.setSceneFormat("", False)
|
||||
theDoc.tokenizeText()
|
||||
theDoc.doHeaders()
|
||||
@@ -471,7 +471,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Paragraph Styles
|
||||
theDoc.theText = (
|
||||
theDoc._theText = (
|
||||
"### Scene\n\n"
|
||||
"@pov: Jane\n"
|
||||
"@char: John\n"
|
||||
@@ -513,7 +513,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
assert getStyle("P8")._pAttr["margin-right"] == ["fo", "1.693cm"]
|
||||
|
||||
# Justified
|
||||
theDoc.theText = (
|
||||
theDoc._theText = (
|
||||
"### Scene\n\n"
|
||||
"Regular paragraph\n\n"
|
||||
"with\nbreak\n\n"
|
||||
@@ -536,7 +536,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
assert getStyle("P9")._pAttr["text-align"] == ["fo", "left"]
|
||||
|
||||
# Page Breaks
|
||||
theDoc.theText = (
|
||||
theDoc._theText = (
|
||||
"## Chapter One\n\n"
|
||||
"Text\n\n"
|
||||
"## Chapter Two\n\n"
|
||||
@@ -568,11 +568,11 @@ def testCoreToOdt_ConvertDirect(mockGUI):
|
||||
mockGUI.theIndex = NWIndex(theProject)
|
||||
theDoc = ToOdt(theProject, isFlat=True)
|
||||
|
||||
theDoc.isNovel = True
|
||||
theDoc._isNovel = True
|
||||
|
||||
# Justified
|
||||
theDoc = ToOdt(theProject, isFlat=True)
|
||||
theDoc.theTokens = [
|
||||
theDoc._theTokens = [
|
||||
(theDoc.T_TEXT, 1, "This is a paragraph", [], theDoc.A_JUSTIFY),
|
||||
(theDoc.T_EMPTY, 1, "", None, theDoc.A_NONE),
|
||||
]
|
||||
@@ -593,7 +593,7 @@ def testCoreToOdt_ConvertDirect(mockGUI):
|
||||
|
||||
# Page Break After
|
||||
theDoc = ToOdt(theProject, isFlat=True)
|
||||
theDoc.theTokens = [
|
||||
theDoc._theTokens = [
|
||||
(theDoc.T_TEXT, 1, "This is a paragraph", [], theDoc.A_PBA),
|
||||
(theDoc.T_EMPTY, 1, "", None, theDoc.A_NONE),
|
||||
]
|
||||
@@ -623,12 +623,12 @@ def testCoreToOdt_SaveFlat(mockGUI, fncDir, outDir, refDir):
|
||||
mockGUI.theIndex = NWIndex(theProject)
|
||||
|
||||
theDoc = ToOdt(theProject, isFlat=True)
|
||||
theDoc.isNovel = True
|
||||
theDoc._isNovel = True
|
||||
assert theDoc.setLanguage(None) is False
|
||||
assert theDoc.setLanguage("nb_NO") is True
|
||||
theDoc.setColourHeaders(True)
|
||||
|
||||
theDoc.theText = (
|
||||
theDoc._theText = (
|
||||
"## Chapter One\n\n"
|
||||
"Text\n\n"
|
||||
"## Chapter Two\n\n"
|
||||
@@ -660,9 +660,9 @@ def testCoreToOdt_SaveFull(mockGUI, fncDir, outDir, refDir):
|
||||
mockGUI.theIndex = NWIndex(theProject)
|
||||
|
||||
theDoc = ToOdt(theProject, isFlat=False)
|
||||
theDoc.isNovel = True
|
||||
theDoc._isNovel = True
|
||||
|
||||
theDoc.theText = (
|
||||
theDoc._theText = (
|
||||
"## Chapter One\n\n"
|
||||
"Text\n\n"
|
||||
"## Chapter Two\n\n"
|
||||
|
||||
Reference in New Issue
Block a user