Merge branch 'dev' into feature/build_gui
This commit is contained in:
@@ -59,9 +59,9 @@ __license__ = "GPLv3"
|
||||
__author__ = "Veronica Berglyd Olsen"
|
||||
__maintainer__ = "Veronica Berglyd Olsen"
|
||||
__email__ = "code@vkbo.net"
|
||||
__version__ = "2.0.6"
|
||||
__hexversion__ = "0x020006f0"
|
||||
__date__ = "2023-02-26"
|
||||
__version__ = "2.0.7"
|
||||
__hexversion__ = "0x020007f0"
|
||||
__date__ = "2023-04-16"
|
||||
__status__ = "Stable"
|
||||
__domain__ = "novelwriter.io"
|
||||
__url__ = "https://novelwriter.io"
|
||||
|
||||
@@ -135,5 +135,16 @@ Tree now also receives focus automatically when a new Project Item is created.</
|
||||
<p>The backlinks in the Reference Panel below the Document Viewer were no longer working. They have
|
||||
now been fixed. They were broken due to a change in the link format in 2.0.</p>
|
||||
|
||||
<h3>Patch 2.0.7 – 16 April 2023</h3>
|
||||
|
||||
<p>This is a patch release that fixes a few issues and adds a Japanese translation.</p>
|
||||
<p>The issues were mostly related to spell checking. In particular, issues with finding the word
|
||||
boundary when using underscore characters for italics markup. These issues should now be resolved.
|
||||
In addition, escaped markup characters are now renderred properly in HTML and ODT build formats.</p>
|
||||
<p>A few usability improvements have also been made. The Add Item menu in the project tree no
|
||||
longer shows the options to create Novel Documents when an item in the tree is selected that cannot
|
||||
hold such a document. In addition, the "Change Label" context menu entry has been changed to say
|
||||
"Rename", which is a more logical choice.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -26,7 +26,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import logging
|
||||
|
||||
from novelwriter.constants import nwKeyWords, nwLabels, nwHtmlUnicode
|
||||
from novelwriter.core.tokenizer import Tokenizer
|
||||
from novelwriter.core.tokenizer import Tokenizer, stripEscape
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -269,7 +269,7 @@ class ToHtml(Tokenizer):
|
||||
parStyle = hStyle
|
||||
for xPos, xLen, xFmt in reversed(tFormat):
|
||||
tTemp = tTemp[:xPos] + htmlTags[xFmt] + tTemp[xPos+xLen:]
|
||||
thisPar.append(tTemp.rstrip())
|
||||
thisPar.append(stripEscape(tTemp.rstrip()))
|
||||
|
||||
elif tType == self.T_SYNOPSIS and self._doSynopsis:
|
||||
tmpResult.append(self._formatSynopsis(tText))
|
||||
|
||||
@@ -40,6 +40,17 @@ from novelwriter.constants import nwConst, nwRegEx, nwUnicode
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def stripEscape(text):
|
||||
"""Helper function to strip escaped markdown characters from
|
||||
paragraph text.
|
||||
"""
|
||||
if "\\" in text:
|
||||
# Checking first is slightly slower when there are escaped
|
||||
# characters in the text, but significantly faster when not
|
||||
return text.replace(r"\*", "*").replace(r"\~", "~").replace(r"\_", "_")
|
||||
return text
|
||||
|
||||
|
||||
class Tokenizer(ABC):
|
||||
|
||||
# In-Text Format
|
||||
@@ -340,23 +351,6 @@ class Tokenizer(ABC):
|
||||
|
||||
return
|
||||
|
||||
def doPostProcessing(self):
|
||||
"""Do some postprocessing. Overloaded by subclasses. This just
|
||||
does the standard escaped characters.
|
||||
"""
|
||||
escapeDict = {
|
||||
r"\*": "*",
|
||||
r"\~": "~",
|
||||
r"\_": "_",
|
||||
}
|
||||
escReplace = re.compile(
|
||||
"|".join([re.escape(k) for k in escapeDict.keys()]), flags=re.DOTALL
|
||||
)
|
||||
self._theResult = escReplace.sub(
|
||||
lambda x: escapeDict[x.group(0)], self._theResult
|
||||
)
|
||||
return
|
||||
|
||||
def tokenizeText(self):
|
||||
"""Scan the text for either lines starting with specific
|
||||
characters that indicate headers, comments, commands etc, or
|
||||
|
||||
@@ -32,7 +32,7 @@ from zipfile import ZipFile
|
||||
from datetime import datetime
|
||||
|
||||
from novelwriter.constants import nwKeyWords, nwLabels
|
||||
from novelwriter.core.tokenizer import Tokenizer
|
||||
from novelwriter.core.tokenizer import Tokenizer, stripEscape
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1356,16 +1356,17 @@ class XMLParagraph:
|
||||
|
||||
return
|
||||
|
||||
def appendText(self, tText):
|
||||
def appendText(self, text):
|
||||
"""Append text to the XML element. We do this one character at
|
||||
the time in order to be able to process line breaks, tabs and
|
||||
spaces separately. Multiple spaces above one are concatenated
|
||||
into a single tag, and must therefore be processed separately.
|
||||
"""
|
||||
text = stripEscape(text)
|
||||
nSpaces = 0
|
||||
self._rawTxt += tText
|
||||
self._rawTxt += text
|
||||
|
||||
for c in tText:
|
||||
for c in text:
|
||||
if c == " ":
|
||||
nSpaces += 1
|
||||
continue
|
||||
|
||||
@@ -224,13 +224,11 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
hReg.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
|
||||
self.rxRules.append((hReg, regRules))
|
||||
|
||||
# Build a QRegExp for spell checker
|
||||
# Build a QRegExp for the spell checker
|
||||
# Include additional characters that the highlighter should
|
||||
# consider to be word separators
|
||||
wordSep = r"\-_\+/"
|
||||
wordSep += nwUnicode.U_ENDASH
|
||||
wordSep += nwUnicode.U_EMDASH
|
||||
self.spellRx = QRegularExpression(r"\b[^\s"+wordSep+r"]+\b")
|
||||
uCode = nwUnicode.U_ENDASH + nwUnicode.U_EMDASH
|
||||
self.spellRx = QRegularExpression(r"\b[^\s\-\+\/" + uCode + r"]+\b")
|
||||
self.spellRx.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
|
||||
|
||||
return True
|
||||
@@ -389,7 +387,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
if not self.spellCheck:
|
||||
return
|
||||
|
||||
rxSpell = self.spellRx.globalMatch(theText, 0)
|
||||
rxSpell = self.spellRx.globalMatch(theText.replace("_", " "), 0)
|
||||
while rxSpell.hasNext():
|
||||
rxMatch = rxSpell.next()
|
||||
if not self.spEnchant.checkWord(rxMatch.captured(0)):
|
||||
|
||||
@@ -188,7 +188,6 @@ class GuiDocViewer(QTextBrowser):
|
||||
aDoc.doPreProcessing()
|
||||
aDoc.tokenizeText()
|
||||
aDoc.doConvert()
|
||||
aDoc.doPostProcessing()
|
||||
except Exception:
|
||||
logger.error("Failed to generate preview for document with handle '%s'", tHandle)
|
||||
logException()
|
||||
|
||||
@@ -771,7 +771,6 @@ class GuiBuildNovel(QDialog):
|
||||
bldObj.doHeaders()
|
||||
if doConvert:
|
||||
bldObj.doConvert()
|
||||
bldObj.doPostProcessing()
|
||||
|
||||
except Exception:
|
||||
logger.error("Failed to build document '%s'", tItem.itemHandle)
|
||||
|
||||
Reference in New Issue
Block a user