diff --git a/novelwriter/formats/todocx.py b/novelwriter/formats/todocx.py index 7c56e29f..1ea7d6b9 100644 --- a/novelwriter/formats/todocx.py +++ b/novelwriter/formats/todocx.py @@ -255,24 +255,19 @@ class ToDocX(Tokenizer): self._processFragments(par, S_NORM, tText, tFormat) elif tType == BlockTyp.TITLE: - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._processFragments(par, S_TITLE, tHead, tFormat) + self._processFragments(par, S_TITLE, tText, tFormat) elif tType == BlockTyp.HEAD1: - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._processFragments(par, S_HEAD1, tHead, tFormat) + self._processFragments(par, S_HEAD1, tText, tFormat) elif tType == BlockTyp.HEAD2: - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._processFragments(par, S_HEAD2, tHead, tFormat) + self._processFragments(par, S_HEAD2, tText, tFormat) elif tType == BlockTyp.HEAD3: - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._processFragments(par, S_HEAD3, tHead, tFormat) + self._processFragments(par, S_HEAD3, tText, tFormat) elif tType == BlockTyp.HEAD4: - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._processFragments(par, S_HEAD4, tHead, tFormat) + self._processFragments(par, S_HEAD4, tText, tFormat) elif tType == BlockTyp.SEP: self._processFragments(par, S_SEP, tText) diff --git a/novelwriter/formats/tohtml.py b/novelwriter/formats/tohtml.py index d129349f..2f8be4ce 100644 --- a/novelwriter/formats/tohtml.py +++ b/novelwriter/formats/tohtml.py @@ -30,7 +30,7 @@ from pathlib import Path from time import time from novelwriter.common import formatTimeStamp -from novelwriter.constants import nwHeadFmt, nwHtmlUnicode +from novelwriter.constants import nwHtmlUnicode from novelwriter.core.project import NWProject from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape from novelwriter.formats.tokenizer import Tokenizer @@ -211,23 +211,23 @@ class ToHtml(Tokenizer): lines.append(f"{self._formatText(tText, tFmt)}

\n") elif tType == BlockTyp.TITLE: - tHead = tText.replace(nwHeadFmt.BR, "
") + tHead = tText.replace("\n", "
") lines.append(f"

{aNm}{tHead}

\n") elif tType == BlockTyp.HEAD1: - tHead = tText.replace(nwHeadFmt.BR, "
") + tHead = tText.replace("\n", "
") lines.append(f"<{h1}{h1Cl}{hStyle}>{aNm}{tHead}\n") elif tType == BlockTyp.HEAD2: - tHead = tText.replace(nwHeadFmt.BR, "
") + tHead = tText.replace("\n", "
") lines.append(f"<{h2}{hStyle}>{aNm}{tHead}\n") elif tType == BlockTyp.HEAD3: - tHead = tText.replace(nwHeadFmt.BR, "
") + tHead = tText.replace("\n", "
") lines.append(f"<{h3}{hStyle}>{aNm}{tHead}\n") elif tType == BlockTyp.HEAD4: - tHead = tText.replace(nwHeadFmt.BR, "
") + tHead = tText.replace("\n", "
") lines.append(f"<{h4}{hStyle}>{aNm}{tHead}\n") elif tType == BlockTyp.SEP: diff --git a/novelwriter/formats/tokenizer.py b/novelwriter/formats/tokenizer.py index f01d6e85..1dd83767 100644 --- a/novelwriter/formats/tokenizer.py +++ b/novelwriter/formats/tokenizer.py @@ -1187,6 +1187,7 @@ class HeadingFormatter: def apply(self, hFormat: str, text: str, nHead: int) -> str: """Apply formatting to a specific heading.""" hFormat = hFormat.replace(nwHeadFmt.TITLE, text) + hFormat = hFormat.replace(nwHeadFmt.BR, "\n") hFormat = hFormat.replace(nwHeadFmt.CH_NUM, str(self._chCount)) hFormat = hFormat.replace(nwHeadFmt.SC_NUM, str(self._scChCount)) hFormat = hFormat.replace(nwHeadFmt.SC_ABS, str(self._scAbsCount)) diff --git a/novelwriter/formats/tomarkdown.py b/novelwriter/formats/tomarkdown.py index db1627be..61111091 100644 --- a/novelwriter/formats/tomarkdown.py +++ b/novelwriter/formats/tomarkdown.py @@ -27,7 +27,7 @@ import logging from pathlib import Path -from novelwriter.constants import nwHeadFmt, nwUnicode +from novelwriter.constants import nwUnicode from novelwriter.core.project import NWProject from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt from novelwriter.formats.tokenizer import Tokenizer @@ -113,23 +113,23 @@ class ToMarkdown(Tokenizer): lines.append(f"{tTemp}\n\n") elif tType == BlockTyp.TITLE: - tHead = tText.replace(nwHeadFmt.BR, " - ") + tHead = tText.replace("\n", " - ") lines.append(f"# {tHead}\n\n") elif tType == BlockTyp.HEAD1: - tHead = tText.replace(nwHeadFmt.BR, " - ") + tHead = tText.replace("\n", " - ") lines.append(f"# {tHead}\n\n") elif tType == BlockTyp.HEAD2: - tHead = tText.replace(nwHeadFmt.BR, " - ") + tHead = tText.replace("\n", " - ") lines.append(f"## {tHead}\n\n") elif tType == BlockTyp.HEAD3: - tHead = tText.replace(nwHeadFmt.BR, " - ") + tHead = tText.replace("\n", " - ") lines.append(f"### {tHead}\n\n") elif tType == BlockTyp.HEAD4: - tHead = tText.replace(nwHeadFmt.BR, " - ") + tHead = tText.replace("\n", " - ") lines.append(f"#### {tHead}\n\n") elif tType == BlockTyp.SEP: diff --git a/novelwriter/formats/toodt.py b/novelwriter/formats/toodt.py index b4b61807..4edce58b 100644 --- a/novelwriter/formats/toodt.py +++ b/novelwriter/formats/toodt.py @@ -444,24 +444,19 @@ class ToOdt(Tokenizer): elif tType == BlockTyp.TITLE: # Title must be text:p - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._addTextPar(xText, S_TITLE, oStyle, tHead, isHead=False) + self._addTextPar(xText, S_TITLE, oStyle, tText, isHead=False) elif tType == BlockTyp.HEAD1: - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._addTextPar(xText, S_HEAD1, oStyle, tHead, isHead=True, oLevel="1") + self._addTextPar(xText, S_HEAD1, oStyle, tText, isHead=True, oLevel="1") elif tType == BlockTyp.HEAD2: - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._addTextPar(xText, S_HEAD2, oStyle, tHead, isHead=True, oLevel="2") + self._addTextPar(xText, S_HEAD2, oStyle, tText, isHead=True, oLevel="2") elif tType == BlockTyp.HEAD3: - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._addTextPar(xText, S_HEAD3, oStyle, tHead, isHead=True, oLevel="3") + self._addTextPar(xText, S_HEAD3, oStyle, tText, isHead=True, oLevel="3") elif tType == BlockTyp.HEAD4: - tHead = tText.replace(nwHeadFmt.BR, "\n") - self._addTextPar(xText, S_HEAD4, oStyle, tHead, isHead=True, oLevel="4") + self._addTextPar(xText, S_HEAD4, oStyle, tText, isHead=True, oLevel="4") elif tType == BlockTyp.SEP: self._addTextPar(xText, S_SEP, oStyle, tText) diff --git a/novelwriter/formats/toqdoc.py b/novelwriter/formats/toqdoc.py index 5c478276..295c9745 100644 --- a/novelwriter/formats/toqdoc.py +++ b/novelwriter/formats/toqdoc.py @@ -34,7 +34,7 @@ from PyQt5.QtGui import ( ) from PyQt5.QtPrintSupport import QPrinter -from novelwriter.constants import nwHeadFmt, nwStyles, nwUnicode +from novelwriter.constants import nwStyles, nwUnicode from novelwriter.core.project import NWProject from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt from novelwriter.formats.tokenizer import HEADINGS, Tokenizer @@ -217,7 +217,7 @@ class ToQTextDocument(Tokenizer): elif tType in HEADINGS: bFmt, cFmt = self._genHeadStyle(tType, tMeta, bFmt) newBlock(cursor, bFmt) - cursor.insertText(tText.replace(nwHeadFmt.BR, "\n"), cFmt) + cursor.insertText(tText, cFmt) elif tType == BlockTyp.SEP: newBlock(cursor, bFmt)