Process escapes in docx and qdoc classes (#2410)
This commit is contained in:
@@ -37,7 +37,7 @@ from PyQt6.QtCore import QMargins, QSize
|
|||||||
from novelwriter import __version__
|
from novelwriter import __version__
|
||||||
from novelwriter.common import firstFloat, xmlElement, xmlSubElem
|
from novelwriter.common import firstFloat, xmlElement, xmlSubElem
|
||||||
from novelwriter.constants import nwHeadFmt, nwStyles
|
from novelwriter.constants import nwHeadFmt, nwStyles
|
||||||
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt
|
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
|
||||||
from novelwriter.formats.tokenizer import Tokenizer
|
from novelwriter.formats.tokenizer import Tokenizer
|
||||||
from novelwriter.types import QtHexRgb
|
from novelwriter.types import QtHexRgb
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ class ToDocX(Tokenizer):
|
|||||||
xmlSubElem(rPr, _wTag("color"), attrib={W_VAL: _docXCol(color)})
|
xmlSubElem(rPr, _wTag("color"), attrib={W_VAL: _docXCol(color)})
|
||||||
|
|
||||||
if isinstance(text, str):
|
if isinstance(text, str):
|
||||||
for segment in RX_TEXT.split(text):
|
for segment in RX_TEXT.split(stripEscape(text)):
|
||||||
if segment == "\n":
|
if segment == "\n":
|
||||||
xmlSubElem(xR, _wTag("br"))
|
xmlSubElem(xR, _wTag("br"))
|
||||||
elif segment == "\t":
|
elif segment == "\t":
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ from PyQt6.QtPrintSupport import QPrinter
|
|||||||
|
|
||||||
from novelwriter import __version__
|
from novelwriter import __version__
|
||||||
from novelwriter.constants import nwStyles, nwUnicode
|
from novelwriter.constants import nwStyles, nwUnicode
|
||||||
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt
|
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
|
||||||
from novelwriter.formats.tokenizer import HEADINGS, Tokenizer
|
from novelwriter.formats.tokenizer import HEADINGS, Tokenizer
|
||||||
from novelwriter.types import (
|
from novelwriter.types import (
|
||||||
QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignLeft, QtAlignRight,
|
QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignLeft, QtAlignRight,
|
||||||
@@ -343,7 +343,7 @@ class ToQTextDocument(Tokenizer):
|
|||||||
for pos, fmt, data in tFmt:
|
for pos, fmt, data in tFmt:
|
||||||
|
|
||||||
# Insert buffer with previous format
|
# Insert buffer with previous format
|
||||||
cursor.insertText(temp[start:pos], cFmt)
|
cursor.insertText(stripEscape(temp[start:pos]), cFmt)
|
||||||
|
|
||||||
# Construct next format
|
# Construct next format
|
||||||
if fmt == TextFmt.B_B:
|
if fmt == TextFmt.B_B:
|
||||||
@@ -425,13 +425,12 @@ class ToQTextDocument(Tokenizer):
|
|||||||
if field := data.partition(":")[2]:
|
if field := data.partition(":")[2]:
|
||||||
self._usedFields.append((cursor.position(), field))
|
self._usedFields.append((cursor.position(), field))
|
||||||
cursor.insertText("0", cFmt)
|
cursor.insertText("0", cFmt)
|
||||||
pass
|
|
||||||
|
|
||||||
# Move pos for next pass
|
# Move pos for next pass
|
||||||
start = pos
|
start = pos
|
||||||
|
|
||||||
# Insert whatever is left in the buffer
|
# Insert whatever is left in the buffer
|
||||||
cursor.insertText(temp[start:], cFmt)
|
cursor.insertText(stripEscape(temp[start:]), cFmt)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user