Improve handling of page breaks (#916)
* Remove page break from title and always allow for partition and chapter * Move strip of format string into the Tokenizer class * Fix page breaks in HTML for skip and sep * Update documentation * Update tests * Allow page breaks before scene and section headers * Never hide the scene header and instead default to skip line
This commit is contained in:
committed by
GitHub
parent
da2685131d
commit
299cde9cdf
@@ -75,7 +75,7 @@ def testCoreToHtml_ConvertFormat(mockGUI):
|
||||
theHtml.tokenizeText()
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == (
|
||||
"<h1 class='title' style='text-align: center; page-break-before: always;'>Title</h1>\n"
|
||||
"<h1 class='title' style='text-align: center;'>Title</h1>\n"
|
||||
)
|
||||
|
||||
# Unnumbered
|
||||
@@ -276,7 +276,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
(theHtml.T_EMPTY, 1, "", None, theHtml.A_NONE),
|
||||
]
|
||||
theHtml.doConvert()
|
||||
assert theHtml.theResult == "<p class='sep'>* * *</p>\n"
|
||||
assert theHtml.theResult == "<p class='sep' style='text-align: center;'>* * *</p>\n"
|
||||
|
||||
# Skip
|
||||
theHtml.theTokens = [
|
||||
|
||||
@@ -374,7 +374,7 @@ def testCoreToken_HeaderFormat(mockGUI):
|
||||
|
||||
theToken.tokenizeText()
|
||||
assert theToken.theTokens == [
|
||||
(Tokenizer.T_TITLE, 1, "Title", None, Tokenizer.A_CENTRE | Tokenizer.A_PBB),
|
||||
(Tokenizer.T_TITLE, 1, "Title", None, Tokenizer.A_CENTRE),
|
||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||
]
|
||||
assert theToken.theMarkdown[-1] == "#! Title\n\n"
|
||||
|
||||
@@ -308,7 +308,7 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
assert theDoc.getErrors() == []
|
||||
assert xmlToText(theDoc._xText) == (
|
||||
'<office:text>'
|
||||
'<text:h text:style-name="P3">Title</text:h>'
|
||||
'<text:h text:style-name="Title">Title</text:h>'
|
||||
'</office:text>'
|
||||
)
|
||||
|
||||
@@ -445,9 +445,9 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
assert theDoc.getErrors() == []
|
||||
assert xmlToText(theDoc._xText) == (
|
||||
'<office:text>'
|
||||
'<text:p text:style-name="P4">* * *</text:p>'
|
||||
'<text:p text:style-name="P3">* * *</text:p>'
|
||||
'<text:p text:style-name="Text_Body">Text</text:p>'
|
||||
'<text:p text:style-name="P4">* * *</text:p>'
|
||||
'<text:p text:style-name="P3">* * *</text:p>'
|
||||
'<text:p text:style-name="Text_Body">Text</text:p>'
|
||||
'</office:text>'
|
||||
)
|
||||
@@ -491,26 +491,26 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
assert xmlToText(theDoc._xText) == (
|
||||
'<office:text>'
|
||||
'<text:h text:style-name="Heading_3" text:outline-level="3">Scene</text:h>'
|
||||
'<text:p text:style-name="P5"><text:span text:style-name="T4">'
|
||||
'<text:p text:style-name="P4"><text:span text:style-name="T4">'
|
||||
'Point of View:</text:span> Jane</text:p>'
|
||||
'<text:p text:style-name="P6"><text:span text:style-name="T4">'
|
||||
'<text:p text:style-name="P5"><text:span text:style-name="T4">'
|
||||
'Characters:</text:span> John</text:p>'
|
||||
'<text:p text:style-name="Text_Meta"><text:span text:style-name="T4">'
|
||||
'Plot:</text:span> Main</text:p>'
|
||||
'<text:p text:style-name="P7">Right align</text:p>'
|
||||
'<text:p text:style-name="P6">Right align</text:p>'
|
||||
'<text:p text:style-name="Text_Body">Left Align</text:p>'
|
||||
'<text:p text:style-name="P4">Centered</text:p>'
|
||||
'<text:p text:style-name="P8">Left indent</text:p>'
|
||||
'<text:p text:style-name="P9">Right indent</text:p>'
|
||||
'<text:p text:style-name="P3">Centered</text:p>'
|
||||
'<text:p text:style-name="P7">Left indent</text:p>'
|
||||
'<text:p text:style-name="P8">Right indent</text:p>'
|
||||
'</office:text>'
|
||||
)
|
||||
assert getStyle("P4")._pAttr["margin-bottom"] == ["fo", "0.000cm"]
|
||||
assert getStyle("P5")._pAttr["margin-bottom"] == ["fo", "0.000cm"]
|
||||
assert getStyle("P6")._pAttr["margin-bottom"] == ["fo", "0.000cm"]
|
||||
assert getStyle("P6")._pAttr["margin-top"] == ["fo", "0.000cm"]
|
||||
assert getStyle("P7")._pAttr["text-align"] == ["fo", "right"]
|
||||
assert getStyle("P4")._pAttr["text-align"] == ["fo", "center"]
|
||||
assert getStyle("P8")._pAttr["margin-left"] == ["fo", "1.693cm"]
|
||||
assert getStyle("P9")._pAttr["margin-right"] == ["fo", "1.693cm"]
|
||||
assert getStyle("P5")._pAttr["margin-top"] == ["fo", "0.000cm"]
|
||||
assert getStyle("P6")._pAttr["text-align"] == ["fo", "right"]
|
||||
assert getStyle("P3")._pAttr["text-align"] == ["fo", "center"]
|
||||
assert getStyle("P7")._pAttr["margin-left"] == ["fo", "1.693cm"]
|
||||
assert getStyle("P8")._pAttr["margin-right"] == ["fo", "1.693cm"]
|
||||
|
||||
# Justified
|
||||
theDoc.theText = (
|
||||
@@ -529,11 +529,11 @@ def testCoreToOdt_Convert(mockGUI):
|
||||
'<office:text>'
|
||||
'<text:h text:style-name="Heading_3" text:outline-level="3">Scene</text:h>'
|
||||
'<text:p text:style-name="Text_Body">Regular paragraph</text:p>'
|
||||
'<text:p text:style-name="P10">with<text:line-break/>break</text:p>'
|
||||
'<text:p text:style-name="P10">Left Align</text:p>'
|
||||
'<text:p text:style-name="P9">with<text:line-break/>break</text:p>'
|
||||
'<text:p text:style-name="P9">Left Align</text:p>'
|
||||
'</office:text>'
|
||||
)
|
||||
assert getStyle("P10")._pAttr["text-align"] == ["fo", "left"]
|
||||
assert getStyle("P9")._pAttr["text-align"] == ["fo", "left"]
|
||||
|
||||
# Page Breaks
|
||||
theDoc.theText = (
|
||||
|
||||
Reference in New Issue
Block a user