Remove the tokenizer post processing stage and instead run it where needed (Issue #1412)

This commit is contained in:
Veronica Berglyd Olsen
2023-04-15 18:30:37 +02:00
parent 6d0455bf28
commit 38f31d6a64
7 changed files with 29 additions and 35 deletions
-4
View File
@@ -574,10 +574,6 @@ def testCoreToHtml_Methods(mockGUI):
assert theHtml.theMarkdown[-1] == (
"Text with <brackets> &amp; short&ndash;dash, long&mdash;dash &hellip;\n\n"
)
theHtml.doPostProcessing()
assert theHtml.theMarkdown[-1] == (
"Text with <brackets> &amp; short&ndash;dash, long&mdash;dash &hellip;\n\n"
)
# Result Size
assert theHtml.getFullResultSize() == 147
+11 -6
View File
@@ -24,7 +24,7 @@ import pytest
from tools import C, buildTestProject, readFile
from novelwriter.core.project import NWProject
from novelwriter.core.tokenizer import Tokenizer
from novelwriter.core.tokenizer import Tokenizer, stripEscape
class BareTokenizer(Tokenizer):
@@ -203,11 +203,6 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
theToken.doPreProcessing()
assert theToken._theText == docTextR
# Post Processing
theToken._theResult = r"This is text with escapes: \** \~~ \__"
theToken.doPostProcessing()
assert theToken.theResult == "This is text with escapes: ** ~~ __"
# Save File
savePath = fncPath / "dump.nwd"
theToken.saveRawMarkdown(savePath)
@@ -223,6 +218,16 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
# END Test testCoreToken_TextOps
@pytest.mark.core
def testCoreToken_StripEscape():
"""Test the stripEscape helper function.
"""
text = r"This is text with escapes: \** \~~ \__"
assert stripEscape(text) == "This is text with escapes: ** ~~ __"
return
@pytest.mark.core
def testCoreToken_HeaderFormat(mockGUI):
"""Test the tokenization of header formats in the Tokenizer class.