Simplify core variables in tokenizer
This commit is contained in:
@@ -42,7 +42,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
theHtml._isFirst = True
|
||||
|
||||
# Header 1
|
||||
theHtml._theText = "# Partition\n"
|
||||
theHtml._text = "# Partition\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -50,7 +50,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Header 2
|
||||
theHtml._theText = "## Chapter Title\n"
|
||||
theHtml._text = "## Chapter Title\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -58,19 +58,19 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Header 3
|
||||
theHtml._theText = "### Scene Title\n"
|
||||
theHtml._text = "### Scene Title\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h2>Scene Title</h2>\n"
|
||||
|
||||
# Header 4
|
||||
theHtml._theText = "#### Section Title\n"
|
||||
theHtml._text = "#### Section Title\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h3>Section Title</h3>\n"
|
||||
|
||||
# Title
|
||||
theHtml._theText = "#! Title\n"
|
||||
theHtml._text = "#! Title\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -78,7 +78,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Unnumbered
|
||||
theHtml._theText = "##! Prologue\n"
|
||||
theHtml._text = "##! Prologue\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h1 style='page-break-before: always;'>Prologue</h1>\n"
|
||||
@@ -92,31 +92,31 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
theHtml.setLinkHeaders(True)
|
||||
|
||||
# Header 1
|
||||
theHtml._theText = "# Heading One\n"
|
||||
theHtml._text = "# 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._text = "## 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._text = "### 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._text = "#### 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._text = "#! Heading One\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -124,7 +124,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Unnumbered
|
||||
theHtml._theText = "##! Heading Two\n"
|
||||
theHtml._text = "##! Heading Two\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<h2><a name='T000001'></a>Heading Two</h2>\n"
|
||||
@@ -133,7 +133,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Text
|
||||
theHtml._theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theHtml._text = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -142,7 +142,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Text w/Hard Break
|
||||
theHtml._theText = "Line one \nLine two \nLine three\n"
|
||||
theHtml._text = "Line one \nLine two \nLine three\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -150,13 +150,13 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Synopsis
|
||||
theHtml._theText = "%synopsis: The synopsis ...\n"
|
||||
theHtml._text = "%synopsis: The synopsis ...\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == ""
|
||||
|
||||
theHtml.setSynopsis(True)
|
||||
theHtml._theText = "%synopsis: The synopsis ...\n"
|
||||
theHtml._text = "%synopsis: The synopsis ...\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -164,13 +164,13 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Comment
|
||||
theHtml._theText = "% A comment ...\n"
|
||||
theHtml._text = "% A comment ...\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == ""
|
||||
|
||||
theHtml.setComments(True)
|
||||
theHtml._theText = "% A comment ...\n"
|
||||
theHtml._text = "% A comment ...\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -178,13 +178,13 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Keywords
|
||||
theHtml._theText = "@char: Bod, Jane\n"
|
||||
theHtml._text = "@char: Bod, Jane\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == ""
|
||||
|
||||
theHtml.setKeywords(True)
|
||||
theHtml._theText = "@char: Bod, Jane\n"
|
||||
theHtml._text = "@char: Bod, Jane\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -194,7 +194,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._text = "## Chapter\n\n@pov: Bod\n@plot: Main\n@location: Europe\n\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -217,7 +217,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
theHtml.setPreview(True, True)
|
||||
|
||||
# Text (HTML4)
|
||||
theHtml._theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theHtml._text = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -244,7 +244,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
# ==============
|
||||
|
||||
# Title
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_TITLE, 1, "A Title", None, theHtml.A_PBB | theHtml.A_CENTRE),
|
||||
(theHtml.T_EMPTY, 1, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -255,7 +255,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Unnumbered
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_UNNUM, 1, "Prologue", None, theHtml.A_PBB),
|
||||
(theHtml.T_EMPTY, 1, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -269,7 +269,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Separator
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_SEP, 1, "* * *", None, theHtml.A_CENTRE),
|
||||
(theHtml.T_EMPTY, 1, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -277,7 +277,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
assert theHtml.theResult == "<p class='sep' style='text-align: center;'>* * *</p>\n"
|
||||
|
||||
# Skip
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_SKIP, 1, "", None, theHtml.A_NONE),
|
||||
(theHtml.T_EMPTY, 1, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -291,7 +291,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
|
||||
# Align Left
|
||||
theHtml.setStyles(False)
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_LEFT),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -302,7 +302,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
theHtml.setStyles(True)
|
||||
|
||||
# Align Left
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_LEFT),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -311,7 +311,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Align Right
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_RIGHT),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -320,7 +320,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Align Centre
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_CENTRE),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -329,7 +329,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Align Justify
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_JUSTIFY),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -341,7 +341,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Page Break Always
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_HEAD1, 1, "A Title", None, theHtml.A_PBB | theHtml.A_PBA),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
@@ -354,7 +354,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
# ======
|
||||
|
||||
# Indent Left
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_TEXT, 1, "Some text ...", [], theHtml.A_IND_L),
|
||||
(theHtml.T_EMPTY, 2, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -364,7 +364,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
)
|
||||
|
||||
# Indent Right
|
||||
theHtml._theTokens = [
|
||||
theHtml._tokens = [
|
||||
(theHtml.T_TEXT, 1, "Some text ...", [], theHtml.A_IND_R),
|
||||
(theHtml.T_EMPTY, 2, "", None, theHtml.A_NONE),
|
||||
]
|
||||
@@ -387,28 +387,28 @@ def testCoreToHtml_SpecialCases(mockGUI):
|
||||
# Greater/Lesser than symbols
|
||||
# ===========================
|
||||
|
||||
theHtml._theText = "Text with > and < with some **bold text** in it.\n"
|
||||
theHtml._text = "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._text = "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._text = "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._text = "Test > text _<**bold**>_ and more.\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -420,7 +420,7 @@ def testCoreToHtml_SpecialCases(mockGUI):
|
||||
# See: https://github.com/vkbo/novelWriter/issues/950
|
||||
|
||||
theHtml.setComments(True)
|
||||
theHtml._theText = "% Test > text _<**bold**>_ and more.\n"
|
||||
theHtml._text = "% Test > text _<**bold**>_ and more.\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -429,7 +429,7 @@ def testCoreToHtml_SpecialCases(mockGUI):
|
||||
"</p>\n"
|
||||
)
|
||||
|
||||
theHtml._theText = "## Heading <1>\n"
|
||||
theHtml._text = "## Heading <1>\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -440,7 +440,7 @@ def testCoreToHtml_SpecialCases(mockGUI):
|
||||
# ====================
|
||||
# See: https://github.com/vkbo/novelWriter/issues/1412
|
||||
|
||||
theHtml._theText = "Test text \\**_bold_** and more.\n"
|
||||
theHtml._text = "Test text \\**_bold_** and more.\n"
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
@@ -502,7 +502,7 @@ def testCoreToHtml_Complex(mockGUI, fncPath):
|
||||
]
|
||||
|
||||
for i in range(len(docText)):
|
||||
theHtml._theText = docText[i]
|
||||
theHtml._text = docText[i]
|
||||
theHtml.doPreProcessing()
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
@@ -556,7 +556,7 @@ def testCoreToHtml_Methods(mockGUI):
|
||||
|
||||
# Auto-Replace, keep Unicode
|
||||
docText = "Text with <brackets> & short–dash, long—dash …\n"
|
||||
theHtml._theText = docText
|
||||
theHtml._text = docText
|
||||
theHtml.setReplaceUnicode(False)
|
||||
theHtml.doPreProcessing()
|
||||
theHtml.tokenizeText()
|
||||
@@ -567,7 +567,7 @@ def testCoreToHtml_Methods(mockGUI):
|
||||
|
||||
# Auto-Replace, replace Unicode
|
||||
docText = "Text with <brackets> & short–dash, long—dash …\n"
|
||||
theHtml._theText = docText
|
||||
theHtml._text = docText
|
||||
theHtml.setReplaceUnicode(True)
|
||||
theHtml.doPreProcessing()
|
||||
theHtml.tokenizeText()
|
||||
@@ -578,7 +578,7 @@ def testCoreToHtml_Methods(mockGUI):
|
||||
|
||||
# With Preview
|
||||
theHtml.setPreview(True, True)
|
||||
theHtml._theText = docText
|
||||
theHtml._text = docText
|
||||
theHtml.doPreProcessing()
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
|
||||
@@ -169,32 +169,32 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
|
||||
# First Page
|
||||
assert theToken.addRootHeading(C.hPlotRoot) is True
|
||||
assert theToken.theMarkdown[-1] == "# Notes: Plot\n\n"
|
||||
assert theToken._theTokens[-1] == (
|
||||
assert theToken._tokens[-1] == (
|
||||
Tokenizer.T_TITLE, 0, "Notes: Plot", None, Tokenizer.A_CENTRE
|
||||
)
|
||||
|
||||
# Not First Page
|
||||
assert theToken.addRootHeading(C.hPlotRoot) is True
|
||||
assert theToken.theMarkdown[-1] == "# Notes: Plot\n\n"
|
||||
assert theToken._theTokens[-1] == (
|
||||
assert theToken._tokens[-1] == (
|
||||
Tokenizer.T_TITLE, 0, "Notes: Plot", None, Tokenizer.A_CENTRE | Tokenizer.A_PBB
|
||||
)
|
||||
|
||||
# Set Text
|
||||
assert theToken.setText("stuff") is False
|
||||
assert theToken.setText(C.hSceneDoc) is True
|
||||
assert theToken._theText == docText
|
||||
assert theToken._text == docText
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr("novelwriter.constants.nwConst.MAX_DOCSIZE", 100)
|
||||
assert theToken.setText(C.hSceneDoc, docText) is True
|
||||
assert theToken._theText == (
|
||||
assert theToken._text == (
|
||||
"# ERROR\n\n"
|
||||
"Document 'New Scene' is too big (0.00 MB). Skipping.\n\n"
|
||||
)
|
||||
|
||||
assert theToken.setText(C.hSceneDoc, docText) is True
|
||||
assert theToken._theText == docText
|
||||
assert theToken._text == docText
|
||||
|
||||
assert theToken._isNone is False
|
||||
assert theToken._isNovel is True
|
||||
@@ -202,7 +202,7 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
|
||||
|
||||
# Pre Processing
|
||||
theToken.doPreProcessing()
|
||||
assert theToken._theText == docTextR
|
||||
assert theToken._text == docTextR
|
||||
|
||||
# Save File
|
||||
savePath = fncPath / "dump.nwd"
|
||||
@@ -246,10 +246,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
theToken._isNovel = True
|
||||
theToken._isNote = False
|
||||
theToken._isFirst = True
|
||||
theToken._theText = "#! Novel Title\n"
|
||||
theToken._text = "#! Novel Title\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_TITLE, 1, "Novel Title", None, Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -259,10 +259,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
theToken._isNovel = False
|
||||
theToken._isNote = True
|
||||
theToken._isFirst = True
|
||||
theToken._theText = "#! Note Title\n"
|
||||
theToken._text = "#! Note Title\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Note Title", None, Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -275,10 +275,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
theToken._isNovel = True
|
||||
theToken._isNote = False
|
||||
theToken._isFirst = True
|
||||
theToken._theText = "# Novel Title\n"
|
||||
theToken._text = "# Novel Title\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Novel Title", None, Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -288,10 +288,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
theToken._isNovel = False
|
||||
theToken._isNote = True
|
||||
theToken._isFirst = True
|
||||
theToken._theText = "# Note Title\n"
|
||||
theToken._text = "# Note Title\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Note Title", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -303,10 +303,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Story File
|
||||
theToken._isNovel = True
|
||||
theToken._isNote = False
|
||||
theToken._theText = "## Chapter One\n"
|
||||
theToken._text = "## Chapter One\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD2, 1, "Chapter One", None, Tokenizer.A_PBB),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -315,10 +315,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Note File
|
||||
theToken._isNovel = False
|
||||
theToken._isNote = True
|
||||
theToken._theText = "## Heading 2\n"
|
||||
theToken._text = "## Heading 2\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD2, 1, "Heading 2", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -330,10 +330,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Story File
|
||||
theToken._isNovel = True
|
||||
theToken._isNote = False
|
||||
theToken._theText = "### Scene One\n"
|
||||
theToken._text = "### Scene One\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD3, 1, "Scene One", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -342,10 +342,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Note File
|
||||
theToken._isNovel = False
|
||||
theToken._isNote = True
|
||||
theToken._theText = "### Heading 3\n"
|
||||
theToken._text = "### Heading 3\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD3, 1, "Heading 3", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -357,10 +357,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Story File
|
||||
theToken._isNovel = True
|
||||
theToken._isNote = False
|
||||
theToken._theText = "#### A Section\n"
|
||||
theToken._text = "#### A Section\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD4, 1, "A Section", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -369,10 +369,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Note File
|
||||
theToken._isNovel = False
|
||||
theToken._isNote = True
|
||||
theToken._theText = "#### Heading 4\n"
|
||||
theToken._text = "#### Heading 4\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD4, 1, "Heading 4", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -384,10 +384,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Story File
|
||||
theToken._isNovel = True
|
||||
theToken._isNote = False
|
||||
theToken._theText = "#! Title\n"
|
||||
theToken._text = "#! Title\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_TITLE, 1, "Title", None, Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -396,10 +396,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Note File
|
||||
theToken._isNovel = False
|
||||
theToken._isNote = True
|
||||
theToken._theText = "#! Title\n"
|
||||
theToken._text = "#! Title\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Title", None, Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -411,10 +411,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Story File
|
||||
theToken._isNovel = True
|
||||
theToken._isNote = False
|
||||
theToken._theText = "##! Prologue\n"
|
||||
theToken._text = "##! Prologue\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_UNNUM, 1, "Prologue", None, Tokenizer.A_PBB),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -423,10 +423,10 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
# Note File
|
||||
theToken._isNovel = False
|
||||
theToken._isNote = True
|
||||
theToken._theText = "##! Prologue\n"
|
||||
theToken._text = "##! Prologue\n"
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD2, 1, "Prologue", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -444,9 +444,9 @@ def testCoreToken_MetaFormat(mockGUI):
|
||||
theToken.setKeepMarkdown(True)
|
||||
|
||||
# Comment
|
||||
theToken._theText = "% A comment\n"
|
||||
theToken._text = "% A comment\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_COMMENT, 1, "A comment", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -457,15 +457,15 @@ def testCoreToken_MetaFormat(mockGUI):
|
||||
assert theToken.theMarkdown[-1] == "% A comment\n\n"
|
||||
|
||||
# Symopsis
|
||||
theToken._theText = "%synopsis: The synopsis\n"
|
||||
theToken._text = "%synopsis: The synopsis\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_SYNOPSIS, 1, "The synopsis", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
theToken._theText = "% synopsis: The synopsis\n"
|
||||
theToken._text = "% synopsis: The synopsis\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_SYNOPSIS, 1, "The synopsis", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -476,9 +476,9 @@ def testCoreToken_MetaFormat(mockGUI):
|
||||
assert theToken.theMarkdown[-1] == "% synopsis: The synopsis\n\n"
|
||||
|
||||
# Keyword
|
||||
theToken._theText = "@char: Bod\n"
|
||||
theToken._text = "@char: Bod\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_KEYWORD, 1, "char: Bod", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -488,12 +488,12 @@ def testCoreToken_MetaFormat(mockGUI):
|
||||
theToken.tokenizeText()
|
||||
assert theToken.theMarkdown[-1] == "@char: Bod\n\n"
|
||||
|
||||
theToken._theText = "@pov: Bod\n@plot: Main\n@location: Europe\n"
|
||||
theToken._text = "@pov: Bod\n@plot: Main\n@location: Europe\n"
|
||||
theToken.tokenizeText()
|
||||
styTop = Tokenizer.A_NONE | Tokenizer.A_Z_BTMMRG
|
||||
styMid = Tokenizer.A_NONE | Tokenizer.A_Z_BTMMRG | Tokenizer.A_Z_TOPMRG
|
||||
styBtm = Tokenizer.A_NONE | Tokenizer.A_Z_TOPMRG
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_KEYWORD, 1, "pov: Bod", None, styTop),
|
||||
(Tokenizer.T_KEYWORD, 2, "plot: Main", None, styMid),
|
||||
(Tokenizer.T_KEYWORD, 3, "location: Europe", None, styBtm),
|
||||
@@ -515,7 +515,7 @@ def testCoreToken_MarginFormat(mockGUI):
|
||||
# Alignment and Indentation
|
||||
dblIndent = Tokenizer.A_IND_L | Tokenizer.A_IND_R
|
||||
rIndAlign = Tokenizer.A_RIGHT | Tokenizer.A_IND_R
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"Some regular text\n\n"
|
||||
"Some left-aligned text <<\n\n"
|
||||
">> Some right-aligned text\n\n"
|
||||
@@ -526,7 +526,7 @@ def testCoreToken_MarginFormat(mockGUI):
|
||||
">> Right-indent, right-aligned <\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_TEXT, 1, "Some regular text", [], Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_TEXT, 3, "Some left-aligned text", [], Tokenizer.A_LEFT),
|
||||
@@ -568,9 +568,9 @@ def testCoreToken_TextFormat(mockGUI):
|
||||
theToken.setKeepMarkdown(True)
|
||||
|
||||
# Text
|
||||
theToken._theText = "Some plain text\non two lines\n\n\n"
|
||||
theToken._text = "Some plain text\non two lines\n\n\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_TEXT, 1, "Some plain text", [], Tokenizer.A_NONE),
|
||||
(Tokenizer.T_TEXT, 2, "on two lines", [], Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 3, "", None, Tokenizer.A_NONE),
|
||||
@@ -581,7 +581,7 @@ def testCoreToken_TextFormat(mockGUI):
|
||||
|
||||
theToken.setBodyText(False)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_EMPTY, 3, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||
@@ -590,9 +590,9 @@ def testCoreToken_TextFormat(mockGUI):
|
||||
theToken.setBodyText(True)
|
||||
|
||||
# Text Emphasis
|
||||
theToken._theText = "Some **bolded text** on this lines\n"
|
||||
theToken._text = "Some **bolded text** on this lines\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(
|
||||
Tokenizer.T_TEXT, 1,
|
||||
"Some **bolded text** on this lines",
|
||||
@@ -606,9 +606,9 @@ def testCoreToken_TextFormat(mockGUI):
|
||||
]
|
||||
assert theToken.theMarkdown[-1] == "Some **bolded text** on this lines\n\n"
|
||||
|
||||
theToken._theText = "Some _italic text_ on this lines\n"
|
||||
theToken._text = "Some _italic text_ on this lines\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(
|
||||
Tokenizer.T_TEXT, 1,
|
||||
"Some _italic text_ on this lines",
|
||||
@@ -622,9 +622,9 @@ def testCoreToken_TextFormat(mockGUI):
|
||||
]
|
||||
assert theToken.theMarkdown[-1] == "Some _italic text_ on this lines\n\n"
|
||||
|
||||
theToken._theText = "Some **_bold italic text_** on this lines\n"
|
||||
theToken._text = "Some **_bold italic text_** on this lines\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(
|
||||
Tokenizer.T_TEXT, 1,
|
||||
"Some **_bold italic text_** on this lines",
|
||||
@@ -640,9 +640,9 @@ def testCoreToken_TextFormat(mockGUI):
|
||||
]
|
||||
assert theToken.theMarkdown[-1] == "Some **_bold italic text_** on this lines\n\n"
|
||||
|
||||
theToken._theText = "Some ~~strikethrough text~~ on this lines\n"
|
||||
theToken._text = "Some ~~strikethrough text~~ on this lines\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(
|
||||
Tokenizer.T_TEXT, 1,
|
||||
"Some ~~strikethrough text~~ on this lines",
|
||||
@@ -656,9 +656,9 @@ def testCoreToken_TextFormat(mockGUI):
|
||||
]
|
||||
assert theToken.theMarkdown[-1] == "Some ~~strikethrough text~~ on this lines\n\n"
|
||||
|
||||
theToken._theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theToken._text = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(
|
||||
Tokenizer.T_TEXT, 1,
|
||||
"Some **nested bold and _italic_ and ~~strikethrough~~ text** here",
|
||||
@@ -704,44 +704,44 @@ def testCoreToken_SpecialFormat(mockGUI):
|
||||
|
||||
# Command wo/Space
|
||||
theToken._isFirst = True
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[NEWPAGE]\n\n"
|
||||
"# Title Two\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == correctResp
|
||||
assert theToken._tokens == correctResp
|
||||
|
||||
# Command w/Space
|
||||
theToken._isFirst = True
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[NEW PAGE]\n\n"
|
||||
"# Title Two\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == correctResp
|
||||
assert theToken._tokens == correctResp
|
||||
|
||||
# Trailing Spaces
|
||||
theToken._isFirst = True
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[NEW PAGE] \t\n\n"
|
||||
"# Title Two\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == correctResp
|
||||
assert theToken._tokens == correctResp
|
||||
|
||||
# Single Empty Paragraph
|
||||
# ======================
|
||||
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[VSPACE] \n\n"
|
||||
"Some text to go here ...\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Title One", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_SKIP, 3, "", None, Tokenizer.A_NONE),
|
||||
@@ -755,13 +755,13 @@ def testCoreToken_SpecialFormat(mockGUI):
|
||||
# =========================
|
||||
|
||||
# One Skip
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[VSPACE:1] \n\n"
|
||||
"Some text to go here ...\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Title One", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_SKIP, 3, "", None, Tokenizer.A_NONE),
|
||||
@@ -772,13 +772,13 @@ def testCoreToken_SpecialFormat(mockGUI):
|
||||
]
|
||||
|
||||
# Three Skips
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[VSPACE:3] \n\n"
|
||||
"Some text to go here ...\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Title One", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_SKIP, 3, "", None, Tokenizer.A_NONE),
|
||||
@@ -791,13 +791,13 @@ def testCoreToken_SpecialFormat(mockGUI):
|
||||
]
|
||||
|
||||
# Malformed Command, Case 1
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[VSPACE:3xa] \n\n"
|
||||
"Some text to go here ...\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Title One", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||
@@ -807,13 +807,13 @@ def testCoreToken_SpecialFormat(mockGUI):
|
||||
]
|
||||
|
||||
# Malformed Command, Case 2
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[VSPACE:3.5]\n\n"
|
||||
"Some text to go here ...\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Title One", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||
@@ -823,13 +823,13 @@ def testCoreToken_SpecialFormat(mockGUI):
|
||||
]
|
||||
|
||||
# Malformed Command, Case 3
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[VSPACE:-1]\n\n"
|
||||
"Some text to go here ...\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Title One", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||
@@ -842,14 +842,14 @@ def testCoreToken_SpecialFormat(mockGUI):
|
||||
# ==============================
|
||||
|
||||
# Single Skip
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[NEW PAGE]\n\n"
|
||||
"[VSPACE]\n\n"
|
||||
"Some text to go here ...\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Title One", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||
@@ -861,14 +861,14 @@ def testCoreToken_SpecialFormat(mockGUI):
|
||||
]
|
||||
|
||||
# Multiple Skip
|
||||
theToken._theText = (
|
||||
theToken._text = (
|
||||
"# Title One\n\n"
|
||||
"[NEW PAGE]\n\n"
|
||||
"[VSPACE:3]\n\n"
|
||||
"Some text to go here ...\n\n"
|
||||
)
|
||||
theToken.tokenizeText()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "Title One", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||
@@ -894,7 +894,7 @@ def testCoreToken_ProcessHeaders(mockGUI):
|
||||
theToken = BareTokenizer(theProject)
|
||||
|
||||
# Nothing
|
||||
theToken._theText = "Some text ...\n"
|
||||
theToken._text = "Some text ...\n"
|
||||
assert theToken.doHeaders() is False
|
||||
theToken._isNone = True
|
||||
assert theToken.doHeaders() is False
|
||||
@@ -917,22 +917,22 @@ def testCoreToken_ProcessHeaders(mockGUI):
|
||||
|
||||
# H1: Title, First Page
|
||||
assert theToken._isFirst is True
|
||||
theToken._theText = "# Part One\n"
|
||||
theToken._text = "# Part One\n"
|
||||
theToken.setTitleFormat(f"T: {nwHeadFmt.TITLE}")
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "T: Part One", None, Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H1: Title, Not First Page
|
||||
assert theToken._isFirst is False
|
||||
theToken._theText = "# Part One\n"
|
||||
theToken._text = "# Part One\n"
|
||||
theToken.setTitleFormat(f"T: {nwHeadFmt.TITLE}")
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD1, 1, "T: Part One", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -941,52 +941,52 @@ def testCoreToken_ProcessHeaders(mockGUI):
|
||||
# ========
|
||||
|
||||
# H2: Chapter
|
||||
theToken._theText = "## Chapter One\n"
|
||||
theToken._text = "## Chapter One\n"
|
||||
theToken.setChapterFormat(f"C: {nwHeadFmt.TITLE}")
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD2, 1, "C: Chapter One", None, Tokenizer.A_PBB),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H2: Unnumbered Chapter
|
||||
theToken._theText = "##! Prologue\n"
|
||||
theToken._text = "##! Prologue\n"
|
||||
theToken.setUnNumberedFormat(f"U: {nwHeadFmt.TITLE}")
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_UNNUM, 1, "U: Prologue", None, Tokenizer.A_PBB),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H2: Chapter Word Number
|
||||
theToken._theText = "## Chapter\n"
|
||||
theToken._text = "## Chapter\n"
|
||||
theToken.setChapterFormat(f"Chapter {nwHeadFmt.CH_WORD}")
|
||||
theToken._hFormatter._chCount = 0
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD2, 1, "Chapter One", None, Tokenizer.A_PBB),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H2: Chapter Roman Number Upper Case
|
||||
theToken._theText = "## Chapter\n"
|
||||
theToken._text = "## Chapter\n"
|
||||
theToken.setChapterFormat(f"Chapter {nwHeadFmt.CH_ROMU}")
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD2, 1, "Chapter II", None, Tokenizer.A_PBB),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H2: Chapter Roman Number Lower Case
|
||||
theToken._theText = "## Chapter\n"
|
||||
theToken._text = "## Chapter\n"
|
||||
theToken.setChapterFormat(f"Chapter {nwHeadFmt.CH_ROML}")
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD2, 1, "Chapter iii", None, Tokenizer.A_PBB),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -995,89 +995,89 @@ def testCoreToken_ProcessHeaders(mockGUI):
|
||||
# ======
|
||||
|
||||
# H3: Scene w/Title
|
||||
theToken._theText = "### Scene One\n"
|
||||
theToken._text = "### Scene One\n"
|
||||
theToken.setSceneFormat(f"S: {nwHeadFmt.TITLE}", False)
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD3, 1, "S: Scene One", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H3: Scene Hidden wo/Format
|
||||
theToken._theText = "### Scene One\n"
|
||||
theToken._text = "### Scene One\n"
|
||||
theToken.setSceneFormat("", True)
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H3: Scene wo/Format, first
|
||||
theToken._theText = "### Scene One\n"
|
||||
theToken._text = "### Scene One\n"
|
||||
theToken.setSceneFormat("", False)
|
||||
theToken._firstScene = True
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H3: Scene wo/Format, not first
|
||||
theToken._theText = "### Scene One\n"
|
||||
theToken._text = "### Scene One\n"
|
||||
theToken.setSceneFormat("", False)
|
||||
theToken._firstScene = False
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_SKIP, 1, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H3: Scene Separator, first
|
||||
theToken._theText = "### Scene One\n"
|
||||
theToken._text = "### Scene One\n"
|
||||
theToken.setSceneFormat("* * *", False)
|
||||
theToken._firstScene = True
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H3: Scene Separator, not first
|
||||
theToken._theText = "### Scene One\n"
|
||||
theToken._text = "### Scene One\n"
|
||||
theToken.setSceneFormat("* * *", False)
|
||||
theToken._firstScene = False
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_SEP, 1, "* * *", None, Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H3: Scene w/Absolute Number
|
||||
theToken._theText = "### A Scene\n"
|
||||
theToken._text = "### A Scene\n"
|
||||
theToken.setSceneFormat(f"Scene {nwHeadFmt.SC_ABS}", False)
|
||||
theToken._hFormatter._scAbsCount = 0
|
||||
theToken._hFormatter._scChCount = 0
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD3, 1, "Scene 1", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H3: Scene w/Chapter Number
|
||||
theToken._theText = "### A Scene\n"
|
||||
theToken._text = "### A Scene\n"
|
||||
theToken.setSceneFormat(f"Scene {nwHeadFmt.CH_NUM}.{nwHeadFmt.SC_NUM}", False)
|
||||
theToken._hFormatter._scAbsCount = 0
|
||||
theToken._hFormatter._scChCount = 1
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD3, 1, "Scene 3.2", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -1086,41 +1086,41 @@ def testCoreToken_ProcessHeaders(mockGUI):
|
||||
# ========
|
||||
|
||||
# H4: Section Hidden wo/Format
|
||||
theToken._theText = "#### A Section\n"
|
||||
theToken._text = "#### A Section\n"
|
||||
theToken.setSectionFormat(r"", True)
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H4: Section Visible wo/Format
|
||||
theToken._theText = "#### A Section\n"
|
||||
theToken._text = "#### A Section\n"
|
||||
theToken.setSectionFormat("", False)
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_SKIP, 1, "", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H4: Section w/Format
|
||||
theToken._theText = "#### A Section\n"
|
||||
theToken._text = "#### A Section\n"
|
||||
theToken.setSectionFormat(f"X: {nwHeadFmt.TITLE}", False)
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_HEAD4, 1, "X: A Section", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
|
||||
# H4: Section Separator
|
||||
theToken._theText = "#### A Section\n"
|
||||
theToken._text = "#### A Section\n"
|
||||
theToken.setSectionFormat("* * *", False)
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._theTokens == [
|
||||
assert theToken._tokens == [
|
||||
(Tokenizer.T_SEP, 1, "* * *", None, Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
@@ -1128,7 +1128,7 @@ def testCoreToken_ProcessHeaders(mockGUI):
|
||||
# Check the first scene detector
|
||||
assert theToken._firstScene is False
|
||||
theToken._firstScene = True
|
||||
theToken._theText = "Some text ...\n"
|
||||
theToken._text = "Some text ...\n"
|
||||
theToken.tokenizeText()
|
||||
theToken.doHeaders()
|
||||
assert theToken._firstScene is False
|
||||
|
||||
@@ -42,37 +42,37 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
theMD._isFirst = True
|
||||
|
||||
# Header 1
|
||||
theMD._theText = "# Partition\n"
|
||||
theMD._text = "# Partition\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "# Partition\n\n"
|
||||
|
||||
# Header 2
|
||||
theMD._theText = "## Chapter Title\n"
|
||||
theMD._text = "## Chapter Title\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "## Chapter Title\n\n"
|
||||
|
||||
# Header 3
|
||||
theMD._theText = "### Scene Title\n"
|
||||
theMD._text = "### Scene Title\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "### Scene Title\n\n"
|
||||
|
||||
# Header 4
|
||||
theMD._theText = "#### Section Title\n"
|
||||
theMD._text = "#### Section Title\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "#### Section Title\n\n"
|
||||
|
||||
# Title
|
||||
theMD._theText = "#! Title\n"
|
||||
theMD._text = "#! Title\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "# Title\n\n"
|
||||
|
||||
# Unnumbered
|
||||
theMD._theText = "##! Prologue\n"
|
||||
theMD._text = "##! Prologue\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "## Prologue\n\n"
|
||||
@@ -82,7 +82,7 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
|
||||
# Text for GitHub Markdown
|
||||
theMD.setGitHubMarkdown()
|
||||
theMD._theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theMD._text = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == (
|
||||
@@ -91,7 +91,7 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
|
||||
# Text for Standard Markdown
|
||||
theMD.setStandardMarkdown()
|
||||
theMD._theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theMD._text = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == (
|
||||
@@ -99,50 +99,50 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
)
|
||||
|
||||
# Text w/Hard Break
|
||||
theMD._theText = "Line one \nLine two \nLine three\n"
|
||||
theMD._text = "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._text = "%synopsis: The synopsis ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == ""
|
||||
|
||||
theMD.setSynopsis(True)
|
||||
theMD._theText = "%synopsis: The synopsis ...\n"
|
||||
theMD._text = "%synopsis: The synopsis ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "**Synopsis:** The synopsis ...\n\n"
|
||||
|
||||
# Comment
|
||||
theMD._theText = "% A comment ...\n"
|
||||
theMD._text = "% A comment ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == ""
|
||||
|
||||
theMD.setComments(True)
|
||||
theMD._theText = "% A comment ...\n"
|
||||
theMD._text = "% A comment ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "**Comment:** A comment ...\n\n"
|
||||
|
||||
# Keywords
|
||||
theMD._theText = "@char: Bod, Jane\n"
|
||||
theMD._text = "@char: Bod, Jane\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == ""
|
||||
|
||||
theMD.setKeywords(True)
|
||||
theMD._theText = "@char: Bod, Jane\n"
|
||||
theMD._text = "@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._text = "## Chapter\n\n@pov: Bod\n@plot: Main\n@location: Europe\n\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == (
|
||||
@@ -169,7 +169,7 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
|
||||
# ==============
|
||||
|
||||
# Title
|
||||
theMD._theTokens = [
|
||||
theMD._tokens = [
|
||||
(theMD.T_TITLE, 1, "A Title", None, theMD.A_PBB | theMD.A_CENTRE),
|
||||
(theMD.T_EMPTY, 1, "", None, theMD.A_NONE),
|
||||
]
|
||||
@@ -177,7 +177,7 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
|
||||
assert theMD.theResult == "# A Title\n\n"
|
||||
|
||||
# Unnumbered
|
||||
theMD._theTokens = [
|
||||
theMD._tokens = [
|
||||
(theMD.T_UNNUM, 1, "Prologue", None, theMD.A_PBB),
|
||||
(theMD.T_EMPTY, 1, "", None, theMD.A_NONE),
|
||||
]
|
||||
@@ -188,7 +188,7 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Separator
|
||||
theMD._theTokens = [
|
||||
theMD._tokens = [
|
||||
(theMD.T_SEP, 1, "* * *", None, theMD.A_CENTRE),
|
||||
(theMD.T_EMPTY, 1, "", None, theMD.A_NONE),
|
||||
]
|
||||
@@ -196,7 +196,7 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
|
||||
assert theMD.theResult == "* * *\n\n"
|
||||
|
||||
# Skip
|
||||
theMD._theTokens = [
|
||||
theMD._tokens = [
|
||||
(theMD.T_SKIP, 1, "", None, theMD.A_NONE),
|
||||
(theMD.T_EMPTY, 1, "", None, theMD.A_NONE),
|
||||
]
|
||||
@@ -237,7 +237,7 @@ def testCoreToMarkdown_Complex(mockGUI, fncPath):
|
||||
]
|
||||
|
||||
for i in range(len(docText)):
|
||||
theMD._theText = docText[i]
|
||||
theMD._text = docText[i]
|
||||
theMD.doPreProcessing()
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
|
||||
@@ -261,7 +261,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
# =======
|
||||
|
||||
# Header 1
|
||||
theDoc._theText = "# Title\n"
|
||||
theDoc._text = "# Title\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -274,7 +274,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Header 2
|
||||
theDoc._theText = "## Chapter\n"
|
||||
theDoc._text = "## Chapter\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -287,7 +287,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Header 3
|
||||
theDoc._theText = "### Scene\n"
|
||||
theDoc._text = "### Scene\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -300,7 +300,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Header 4
|
||||
theDoc._theText = "#### Section\n"
|
||||
theDoc._text = "#### Section\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -313,7 +313,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Title
|
||||
theDoc._theText = "#! Title\n"
|
||||
theDoc._text = "#! Title\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -326,7 +326,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Unnumbered chapter
|
||||
theDoc._theText = "##! Prologue\n"
|
||||
theDoc._text = "##! Prologue\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -342,7 +342,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
# ==========
|
||||
|
||||
# Nested Text
|
||||
theDoc._theText = "Some ~~nested **bold** and _italics_ text~~ text."
|
||||
theDoc._text = "Some ~~nested **bold** and _italics_ text~~ text."
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -360,7 +360,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Hard Break
|
||||
theDoc._theText = "Some text.\nNext line\n"
|
||||
theDoc._text = "Some text.\nNext line\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -373,7 +373,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Tab
|
||||
theDoc._theText = "\tItem 1\tItem 2\n"
|
||||
theDoc._text = "\tItem 1\tItem 2\n"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -386,7 +386,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Tab in Format
|
||||
theDoc._theText = "Some **bold\ttext**"
|
||||
theDoc._text = "Some **bold\ttext**"
|
||||
theDoc.tokenizeText()
|
||||
theDoc.initDocument()
|
||||
theDoc.doConvert()
|
||||
@@ -400,7 +400,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Multiple Spaces
|
||||
theDoc._theText = (
|
||||
theDoc._text = (
|
||||
"### Scene\n\n"
|
||||
"Hello World\n\n"
|
||||
"Hello World\n\n"
|
||||
@@ -421,7 +421,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Synopsis, Comment, Keywords
|
||||
theDoc._theText = (
|
||||
theDoc._text = (
|
||||
"### Scene\n\n"
|
||||
"@pov: Jane\n\n"
|
||||
"% synopsis: So it begins\n\n"
|
||||
@@ -448,7 +448,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Scene Separator
|
||||
theDoc._theText = "### Scene One\n\nText\n\n### Scene Two\n\nText"
|
||||
theDoc._text = "### Scene One\n\nText\n\n### Scene Two\n\nText"
|
||||
theDoc.setSceneFormat("* * *", False)
|
||||
theDoc.tokenizeText()
|
||||
theDoc.doHeaders()
|
||||
@@ -466,7 +466,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Scene Break
|
||||
theDoc._theText = "### Scene One\n\nText\n\n### Scene Two\n\nText"
|
||||
theDoc._text = "### Scene One\n\nText\n\n### Scene Two\n\nText"
|
||||
theDoc.setSceneFormat("", False)
|
||||
theDoc.tokenizeText()
|
||||
theDoc.doHeaders()
|
||||
@@ -484,7 +484,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
)
|
||||
|
||||
# Paragraph Styles
|
||||
theDoc._theText = (
|
||||
theDoc._text = (
|
||||
"### Scene\n\n"
|
||||
"@pov: Jane\n"
|
||||
"@char: John\n"
|
||||
@@ -526,7 +526,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
assert getStyle("P8")._pAttr["margin-right"] == ["fo", "1.693cm"]
|
||||
|
||||
# Justified
|
||||
theDoc._theText = (
|
||||
theDoc._text = (
|
||||
"### Scene\n\n"
|
||||
"Regular paragraph\n\n"
|
||||
"with\nbreak\n\n"
|
||||
@@ -549,7 +549,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
assert getStyle("P9")._pAttr["text-align"] == ["fo", "left"]
|
||||
|
||||
# Page Breaks
|
||||
theDoc._theText = (
|
||||
theDoc._text = (
|
||||
"## Chapter One\n\n"
|
||||
"Text\n\n"
|
||||
"## Chapter Two\n\n"
|
||||
@@ -584,7 +584,7 @@ def testCoreToOdt_ConvertDirect(mockGUI):
|
||||
|
||||
# Justified
|
||||
theDoc = ToOdt(theProject, isFlat=True)
|
||||
theDoc._theTokens = [
|
||||
theDoc._tokens = [
|
||||
(theDoc.T_TEXT, 1, "This is a paragraph", [], theDoc.A_JUSTIFY),
|
||||
(theDoc.T_EMPTY, 1, "", None, theDoc.A_NONE),
|
||||
]
|
||||
@@ -605,7 +605,7 @@ def testCoreToOdt_ConvertDirect(mockGUI):
|
||||
|
||||
# Page Break After
|
||||
theDoc = ToOdt(theProject, isFlat=True)
|
||||
theDoc._theTokens = [
|
||||
theDoc._tokens = [
|
||||
(theDoc.T_TEXT, 1, "This is a paragraph", [], theDoc.A_PBA),
|
||||
(theDoc.T_EMPTY, 1, "", None, theDoc.A_NONE),
|
||||
]
|
||||
@@ -643,7 +643,7 @@ def testCoreToOdt_SaveFlat(mockGUI, fncPath, tstPaths):
|
||||
assert theDoc.setLanguage("nb_NO") is True
|
||||
theDoc.setColourHeaders(True)
|
||||
|
||||
theDoc._theText = (
|
||||
theDoc._text = (
|
||||
"## Chapter One\n\n"
|
||||
"Text\n\n"
|
||||
"## Chapter Two\n\n"
|
||||
@@ -680,7 +680,7 @@ def testCoreToOdt_SaveFull(mockGUI, fncPath, tstPaths):
|
||||
theDoc = ToOdt(theProject, isFlat=False)
|
||||
theDoc._isNovel = True
|
||||
|
||||
theDoc._theText = (
|
||||
theDoc._text = (
|
||||
"## Chapter One\n\n"
|
||||
"Text\n\n"
|
||||
"## Chapter Two\n\n"
|
||||
|
||||
Reference in New Issue
Block a user