Update tokenizer and converters
This commit is contained in:
@@ -149,7 +149,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
"<p class='break'>Line one<br/>Line two<br/>Line three</p>\n"
|
||||
)
|
||||
|
||||
# Synopsis
|
||||
# Synopsis, Brief
|
||||
html._text = "%synopsis: The synopsis ...\n"
|
||||
html.tokenizeText()
|
||||
html.doConvert()
|
||||
@@ -163,6 +163,14 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
"<p class='synopsis'><strong>Synopsis:</strong> The synopsis ...</p>\n"
|
||||
)
|
||||
|
||||
html.setSynopsis(True)
|
||||
html._text = "%brief: A description ...\n"
|
||||
html.tokenizeText()
|
||||
html.doConvert()
|
||||
assert html.theResult == (
|
||||
"<p class='synopsis'><strong>Brief:</strong> A description ...</p>\n"
|
||||
)
|
||||
|
||||
# Comment
|
||||
html._text = "% A comment ...\n"
|
||||
html.tokenizeText()
|
||||
@@ -610,9 +618,12 @@ def testCoreToHtml_Format(mockGUI):
|
||||
# Export Mode
|
||||
# ===========
|
||||
|
||||
assert html._formatSynopsis("synopsis text") == (
|
||||
assert html._formatSynopsis("synopsis text", True) == (
|
||||
"<p class='synopsis'><strong>Synopsis:</strong> synopsis text</p>\n"
|
||||
)
|
||||
assert html._formatSynopsis("brief text", False) == (
|
||||
"<p class='synopsis'><strong>Brief:</strong> brief text</p>\n"
|
||||
)
|
||||
assert html._formatComments("comment text") == (
|
||||
"<p class='comment'><strong>Comment:</strong> comment text</p>\n"
|
||||
)
|
||||
@@ -632,9 +643,12 @@ def testCoreToHtml_Format(mockGUI):
|
||||
|
||||
html.setPreview(True, True)
|
||||
|
||||
assert html._formatSynopsis("synopsis text") == (
|
||||
assert html._formatSynopsis("synopsis text", True) == (
|
||||
"<p class='comment'><span class='synopsis'>Synopsis:</span> synopsis text</p>\n"
|
||||
)
|
||||
assert html._formatSynopsis("brief text", False) == (
|
||||
"<p class='comment'><span class='synopsis'>Brief:</span> brief text</p>\n"
|
||||
)
|
||||
assert html._formatComments("comment text") == (
|
||||
"<p class='comment'>comment text</p>\n"
|
||||
)
|
||||
|
||||
@@ -471,6 +471,20 @@ def testCoreToken_MetaFormat(mockGUI):
|
||||
tokens.tokenizeText()
|
||||
assert tokens.theMarkdown[-1] == "% synopsis: The synopsis\n\n"
|
||||
|
||||
# Brief
|
||||
tokens.setSynopsis(False)
|
||||
tokens._text = "% brief: A description\n"
|
||||
tokens.tokenizeText()
|
||||
assert tokens._tokens == [
|
||||
(Tokenizer.T_BRIEF, 0, "A description", None, Tokenizer.A_NONE),
|
||||
(Tokenizer.T_EMPTY, 0, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
assert tokens.theMarkdown[-1] == "\n"
|
||||
|
||||
tokens.setSynopsis(True)
|
||||
tokens.tokenizeText()
|
||||
assert tokens.theMarkdown[-1] == "% brief: A description\n\n"
|
||||
|
||||
# Keyword
|
||||
tokens._text = "@char: Bod\n"
|
||||
tokens.tokenizeText()
|
||||
|
||||
@@ -106,7 +106,7 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "Line one \nLine two \nLine three\n\n"
|
||||
|
||||
# Synopsis
|
||||
# Synopsis, Brief
|
||||
theMD._text = "%synopsis: The synopsis ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
@@ -118,6 +118,12 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "**Synopsis:** The synopsis ...\n\n"
|
||||
|
||||
theMD.setSynopsis(True)
|
||||
theMD._text = "%brief: A description ...\n"
|
||||
theMD.tokenizeText()
|
||||
theMD.doConvert()
|
||||
assert theMD.theResult == "**Brief:** A description ...\n\n"
|
||||
|
||||
# Comment
|
||||
theMD._text = "% A comment ...\n"
|
||||
theMD.tokenizeText()
|
||||
|
||||
@@ -447,12 +447,13 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
'</office:text>'
|
||||
)
|
||||
|
||||
# Synopsis, Comment, Keywords
|
||||
# Synopsis, Brief, Comment, Keywords
|
||||
odt._text = (
|
||||
"### Scene\n\n"
|
||||
"@pov: Jane\n\n"
|
||||
"% synopsis: So it begins\n\n"
|
||||
"% a plain comment\n\n"
|
||||
"% brief: Then what\n\n"
|
||||
"% A plain comment\n\n"
|
||||
)
|
||||
odt.setSynopsis(True)
|
||||
odt.setComments(True)
|
||||
@@ -470,7 +471,9 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
'<text:p text:style-name="Text_20_Meta"><text:span text:style-name="T7">'
|
||||
'Synopsis:</text:span> So it begins</text:p>'
|
||||
'<text:p text:style-name="Text_20_Meta"><text:span text:style-name="T7">'
|
||||
'Comment:</text:span> a plain comment</text:p>'
|
||||
'Brief:</text:span> Then what</text:p>'
|
||||
'<text:p text:style-name="Text_20_Meta"><text:span text:style-name="T7">'
|
||||
'Comment:</text:span> A plain comment</text:p>'
|
||||
'</office:text>'
|
||||
)
|
||||
|
||||
@@ -804,9 +807,12 @@ def testCoreToOdt_Format(mockGUI):
|
||||
project = NWProject()
|
||||
odt = ToOdt(project, isFlat=True)
|
||||
|
||||
assert odt._formatSynopsis("synopsis text") == (
|
||||
assert odt._formatSynopsis("synopsis text", True) == (
|
||||
"Synopsis: synopsis text", [(0, ToOdt.FMT_B_B), (9, ToOdt.FMT_B_E)]
|
||||
)
|
||||
assert odt._formatSynopsis("brief text", False) == (
|
||||
"Brief: brief text", [(0, ToOdt.FMT_B_B), (6, ToOdt.FMT_B_E)]
|
||||
)
|
||||
assert odt._formatComments("comment text") == (
|
||||
"Comment: comment text", [(0, ToOdt.FMT_B_B), (8, ToOdt.FMT_B_E)]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user