Update HTML output
This commit is contained in:
@@ -30,7 +30,7 @@ from pathlib import Path
|
|||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from novelwriter.common import formatTimeStamp
|
from novelwriter.common import formatTimeStamp
|
||||||
from novelwriter.constants import nwHtmlUnicode
|
from novelwriter.constants import nwHtmlUnicode, nwStyles
|
||||||
from novelwriter.core.project import NWProject
|
from novelwriter.core.project import NWProject
|
||||||
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
|
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
|
||||||
from novelwriter.formats.tokenizer import Tokenizer
|
from novelwriter.formats.tokenizer import Tokenizer
|
||||||
@@ -296,9 +296,7 @@ class ToHtml(Tokenizer):
|
|||||||
"</style>\n"
|
"</style>\n"
|
||||||
"</head>\n"
|
"</head>\n"
|
||||||
"<body>\n"
|
"<body>\n"
|
||||||
"<article>\n"
|
|
||||||
"{body:s}\n"
|
"{body:s}\n"
|
||||||
"</article>\n"
|
|
||||||
"</body>\n"
|
"</body>\n"
|
||||||
"</html>\n"
|
"</html>\n"
|
||||||
).format(
|
).format(
|
||||||
@@ -345,6 +343,12 @@ class ToHtml(Tokenizer):
|
|||||||
mtSP = self._marginSep[0]
|
mtSP = self._marginSep[0]
|
||||||
mbSP = self._marginSep[1]
|
mbSP = self._marginSep[1]
|
||||||
|
|
||||||
|
fSz0 = nwStyles.H_SIZES[0]
|
||||||
|
fSz1 = nwStyles.H_SIZES[1]
|
||||||
|
fSz2 = nwStyles.H_SIZES[2]
|
||||||
|
fSz3 = nwStyles.H_SIZES[3]
|
||||||
|
fSz4 = nwStyles.H_SIZES[4]
|
||||||
|
|
||||||
font = self._textFont
|
font = self._textFont
|
||||||
fFam = font.family()
|
fFam = font.family()
|
||||||
fSz = font.pointSize()
|
fSz = font.pointSize()
|
||||||
@@ -365,12 +369,25 @@ class ToHtml(Tokenizer):
|
|||||||
styles.append(f"a {{color: {lColor};}}")
|
styles.append(f"a {{color: {lColor};}}")
|
||||||
styles.append(f"mark {{background: {mColor};}}")
|
styles.append(f"mark {{background: {mColor};}}")
|
||||||
styles.append(f"h1, h2, h3, h4 {{color: {hColor}; page-break-after: avoid;}}")
|
styles.append(f"h1, h2, h3, h4 {{color: {hColor}; page-break-after: avoid;}}")
|
||||||
styles.append(f"h1 {{margin-top: {mtH1:.2f}em; margin-bottom: {mbH1:.2f}em;}}")
|
|
||||||
styles.append(f"h2 {{margin-top: {mtH2:.2f}em; margin-bottom: {mbH2:.2f}em;}}")
|
|
||||||
styles.append(f"h3 {{margin-top: {mtH3:.2f}em; margin-bottom: {mbH3:.2f}em;}}")
|
|
||||||
styles.append(f"h4 {{margin-top: {mtH4:.2f}em; margin-bottom: {mbH4:.2f}em;}}")
|
|
||||||
styles.append(
|
styles.append(
|
||||||
f".title {{font-size: 2.5em; margin-top: {mtH0:.2f}em; margin-bottom: {mbH0:.2f}em;}}"
|
f"h1 {{font-size: {fSz1:.2f}em; "
|
||||||
|
f"margin-top: {mtH1:.2f}em; margin-bottom: {mbH1:.2f}em;}}"
|
||||||
|
)
|
||||||
|
styles.append(
|
||||||
|
f"h2 {{font-size: {fSz2:.2f}em; "
|
||||||
|
f"margin-top: {mtH2:.2f}em; margin-bottom: {mbH2:.2f}em;}}"
|
||||||
|
)
|
||||||
|
styles.append(
|
||||||
|
f"h3 {{font-size: {fSz3:.2f}em; "
|
||||||
|
f"margin-top: {mtH3:.2f}em; margin-bottom: {mbH3:.2f}em;}}"
|
||||||
|
)
|
||||||
|
styles.append(
|
||||||
|
f"h4 {{font-size: {fSz4:.2f}em; "
|
||||||
|
f"margin-top: {mtH4:.2f}em; margin-bottom: {mbH4:.2f}em;}}"
|
||||||
|
)
|
||||||
|
styles.append(
|
||||||
|
f".title {{font-size: {fSz0:.2f}em; "
|
||||||
|
f"margin-top: {mtH0:.2f}em; margin-bottom: {mbH0:.2f}em;}}"
|
||||||
)
|
)
|
||||||
styles.append(
|
styles.append(
|
||||||
f".sep {{text-align: center; margin-top: {mtSP:.2f}em; margin-bottom: {mbSP:.2f}em;}}"
|
f".sep {{text-align: center; margin-top: {mtSP:.2f}em; margin-bottom: {mbSP:.2f}em;}}"
|
||||||
|
|||||||
@@ -9,16 +9,15 @@ p {text-align: left; line-height: 150%; margin-top: 0.00em; margin-bottom: 0.60e
|
|||||||
a {color: #4271ae;}
|
a {color: #4271ae;}
|
||||||
mark {background: #ffffa6;}
|
mark {background: #ffffa6;}
|
||||||
h1, h2, h3, h4 {color: #4271ae; page-break-after: avoid;}
|
h1, h2, h3, h4 {color: #4271ae; page-break-after: avoid;}
|
||||||
h1 {margin-top: 1.50em; margin-bottom: 0.60em;}
|
h1 {font-size: 2.00em; margin-top: 1.50em; margin-bottom: 0.60em;}
|
||||||
h2 {margin-top: 1.50em; margin-bottom: 0.60em;}
|
h2 {font-size: 1.75em; margin-top: 1.50em; margin-bottom: 0.60em;}
|
||||||
h3 {margin-top: 1.20em; margin-bottom: 0.60em;}
|
h3 {font-size: 1.50em; margin-top: 1.20em; margin-bottom: 0.60em;}
|
||||||
h4 {margin-top: 1.20em; margin-bottom: 0.60em;}
|
h4 {font-size: 1.25em; margin-top: 1.20em; margin-bottom: 0.60em;}
|
||||||
.title {font-size: 2.5em; margin-top: 1.50em; margin-bottom: 0.60em;}
|
.title {font-size: 2.50em; margin-top: 1.50em; margin-bottom: 0.60em;}
|
||||||
.sep {text-align: center; margin-top: 1.20em; margin-bottom: 1.20em;}
|
.sep {text-align: center; margin-top: 1.20em; margin-bottom: 1.20em;}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<article>
|
|
||||||
<h1 class='title' style='text-align: center;'>Lorem Ipsum</h1>
|
<h1 class='title' style='text-align: center;'>Lorem Ipsum</h1>
|
||||||
<p style='text-align: center;'><strong>By lipsum.com</strong></p>
|
<p style='text-align: center;'><strong>By lipsum.com</strong></p>
|
||||||
<p style='text-align: center;'>Word Count: 4,169</p>
|
<p style='text-align: center;'>Word Count: 4,169</p>
|
||||||
@@ -125,6 +124,5 @@ h4 {margin-top: 1.20em; margin-bottom: 0.60em;}
|
|||||||
<ol>
|
<ol>
|
||||||
<li id='footnote_1'><p><em>Lorem ipsum</em> is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero, with words altered, added, and removed to make it nonsensical and improper Latin. (Source: Wikipedia)</p></li>
|
<li id='footnote_1'><p><em>Lorem ipsum</em> is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero, with words altered, added, and removed to make it nonsensical and improper Latin. (Source: Wikipedia)</p></li>
|
||||||
</ol>
|
</ol>
|
||||||
</article>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
"meta": {
|
"meta": {
|
||||||
"projectName": "Lorem Ipsum",
|
"projectName": "Lorem Ipsum",
|
||||||
"novelAuthor": "lipsum.com",
|
"novelAuthor": "lipsum.com",
|
||||||
"buildTime": 1731526420,
|
"buildTime": 1737835371,
|
||||||
"buildTimeStr": "2024-11-13 20:33:40"
|
"buildTimeStr": "2025-01-25 21:02:51"
|
||||||
},
|
},
|
||||||
"text": {
|
"text": {
|
||||||
"css": [
|
"css": [
|
||||||
@@ -12,11 +12,11 @@
|
|||||||
"a {color: #4271ae;}",
|
"a {color: #4271ae;}",
|
||||||
"mark {background: #ffffa6;}",
|
"mark {background: #ffffa6;}",
|
||||||
"h1, h2, h3, h4 {color: #4271ae; page-break-after: avoid;}",
|
"h1, h2, h3, h4 {color: #4271ae; page-break-after: avoid;}",
|
||||||
"h1 {margin-top: 1.50em; margin-bottom: 0.60em;}",
|
"h1 {font-size: 2.00em; margin-top: 1.50em; margin-bottom: 0.60em;}",
|
||||||
"h2 {margin-top: 1.50em; margin-bottom: 0.60em;}",
|
"h2 {font-size: 1.75em; margin-top: 1.50em; margin-bottom: 0.60em;}",
|
||||||
"h3 {margin-top: 1.20em; margin-bottom: 0.60em;}",
|
"h3 {font-size: 1.50em; margin-top: 1.20em; margin-bottom: 0.60em;}",
|
||||||
"h4 {margin-top: 1.20em; margin-bottom: 0.60em;}",
|
"h4 {font-size: 1.25em; margin-top: 1.20em; margin-bottom: 0.60em;}",
|
||||||
".title {font-size: 2.5em; margin-top: 1.50em; margin-bottom: 0.60em;}",
|
".title {font-size: 2.50em; margin-top: 1.50em; margin-bottom: 0.60em;}",
|
||||||
".sep {text-align: center; margin-top: 1.20em; margin-bottom: 1.20em;}"
|
".sep {text-align: center; margin-top: 1.20em; margin-bottom: 1.20em;}"
|
||||||
],
|
],
|
||||||
"html": [
|
"html": [
|
||||||
|
|||||||
@@ -677,9 +677,7 @@ def testFmtToHtml_Save(mockGUI, fncPath):
|
|||||||
"</style>\n"
|
"</style>\n"
|
||||||
"</head>\n"
|
"</head>\n"
|
||||||
"<body>\n"
|
"<body>\n"
|
||||||
"<article>\n"
|
|
||||||
"{bodyText:s}\n"
|
"{bodyText:s}\n"
|
||||||
"</article>\n"
|
|
||||||
"</body>\n"
|
"</body>\n"
|
||||||
"</html>\n"
|
"</html>\n"
|
||||||
).format(
|
).format(
|
||||||
|
|||||||
Reference in New Issue
Block a user