Add alignment precedence test to HTML tests

This commit is contained in:
Veronica Berglyd Olsen
2025-06-24 00:07:55 +02:00
parent 3c474987b2
commit 979a55d24a
+48 -3
View File
@@ -147,9 +147,6 @@ def testFmtToHtml_ConvertParagraphs(mockGUI):
html._isNovel = True
html._isFirst = True
# Paragraphs
# ==========
# Text
html._text = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
html.tokenizeText()
@@ -280,6 +277,54 @@ def testFmtToHtml_ConvertParagraphs(mockGUI):
)
@pytest.mark.core
def testFmtToHtml_Alignment(mockGUI):
"""Test paragraph alignment in the ToHtml class."""
project = NWProject()
html = ToHtml(project)
html.initDocument()
# Left
html._text = "This is text <<\nspanning multiple\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: left;'>This is text<br>spanning multiple<br>lines</p>\n"
)
# Right
html._text = ">> This is text\nspanning multiple\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: right;'>This is text<br>spanning multiple<br>lines</p>\n"
)
# Centre
html._text = ">> This is text <<\nspanning multiple\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: center;'>This is text<br>spanning multiple<br>lines</p>\n"
)
# Left before Right
html._text = ">> This is text\nspanning multiple <<\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: left;'>This is text<br>spanning multiple<br>lines</p>\n"
)
# Right before Centre
html._text = ">> This is text <<\n>> spanning multiple\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: right;'>This is text<br>spanning multiple<br>lines</p>\n"
)
@pytest.mark.core
def testFmtToHtml_Dialog(mockGUI):
"""Test paragraph formats in the ToHtml class."""