Changed the formatting codes for titles
This commit is contained in:
@@ -565,11 +565,11 @@ class Tokenizer():
|
||||
def _formatHeading(self, theTitle, theText):
|
||||
"""Replaces the %keyword% strings.
|
||||
"""
|
||||
theTitle = theTitle.replace(r"%title%", theText)
|
||||
theTitle = theTitle.replace(r"%chnum%", str(self.numChapter))
|
||||
theTitle = theTitle.replace(r"%scnum%", str(self.numChScene))
|
||||
theTitle = theTitle.replace(r"%scabsnum%", str(self.numAbsScene))
|
||||
theTitle = theTitle.replace(r"%chnumword%", numberToWord(self.numChapter,"en"))
|
||||
theTitle = theTitle.replace(r"%title%", theText)
|
||||
theTitle = theTitle.replace(r"%ch%", str(self.numChapter))
|
||||
theTitle = theTitle.replace(r"%sc1%", str(self.numChScene))
|
||||
theTitle = theTitle.replace(r"%sc2%", str(self.numAbsScene))
|
||||
theTitle = theTitle.replace(r"%chword%", numberToWord(self.numChapter,"en"))
|
||||
return theTitle
|
||||
|
||||
# END Class Tokenizer
|
||||
|
||||
+24
-5
@@ -98,27 +98,37 @@ class GuiBuildNovel(QDialog):
|
||||
self.fmtTitle = QLineEdit()
|
||||
self.fmtTitle.setMaxLength(200)
|
||||
self.fmtTitle.setFixedWidth(220)
|
||||
self.fmtTitle.setText(self.theProject.titleFormat["title"])
|
||||
self.fmtTitle.setText(
|
||||
self._reFmtCodes(self.theProject.titleFormat["title"])
|
||||
)
|
||||
|
||||
self.fmtChapter = QLineEdit()
|
||||
self.fmtChapter.setMaxLength(200)
|
||||
self.fmtChapter.setFixedWidth(220)
|
||||
self.fmtChapter.setText(self.theProject.titleFormat["chapter"])
|
||||
self.fmtChapter.setText(
|
||||
self._reFmtCodes(self.theProject.titleFormat["chapter"])
|
||||
)
|
||||
|
||||
self.fmtUnnumbered = QLineEdit()
|
||||
self.fmtUnnumbered.setMaxLength(200)
|
||||
self.fmtUnnumbered.setFixedWidth(220)
|
||||
self.fmtUnnumbered.setText(self.theProject.titleFormat["unnumbered"])
|
||||
self.fmtUnnumbered.setText(
|
||||
self._reFmtCodes(self.theProject.titleFormat["unnumbered"])
|
||||
)
|
||||
|
||||
self.fmtScene = QLineEdit()
|
||||
self.fmtScene.setMaxLength(200)
|
||||
self.fmtScene.setFixedWidth(220)
|
||||
self.fmtScene.setText(self.theProject.titleFormat["scene"])
|
||||
self.fmtScene.setText(
|
||||
self._reFmtCodes(self.theProject.titleFormat["scene"])
|
||||
)
|
||||
|
||||
self.fmtSection = QLineEdit()
|
||||
self.fmtSection.setMaxLength(200)
|
||||
self.fmtSection.setFixedWidth(220)
|
||||
self.fmtSection.setText(self.theProject.titleFormat["section"])
|
||||
self.fmtSection.setText(
|
||||
self._reFmtCodes(self.theProject.titleFormat["section"])
|
||||
)
|
||||
|
||||
self.titleForm.addWidget(QLabel("Title"), 0, 0, 1, 1, Qt.AlignLeft)
|
||||
self.titleForm.addWidget(self.fmtTitle, 0, 1, 1, 1, Qt.AlignRight)
|
||||
@@ -677,6 +687,15 @@ class GuiBuildNovel(QDialog):
|
||||
)
|
||||
return
|
||||
|
||||
def _reFmtCodes(self, theFormat):
|
||||
"""Translates old formatting codes to new ones.
|
||||
"""
|
||||
theFormat = theFormat.replace(r"%chnum%", r"%ch%")
|
||||
theFormat = theFormat.replace(r"%scnum%", r"%sc1%")
|
||||
theFormat = theFormat.replace(r"%scabsnum%", r"%sc2%")
|
||||
theFormat = theFormat.replace(r"%chnumword%", r"%chword%")
|
||||
return theFormat
|
||||
|
||||
# END Class GuiBuildNovel
|
||||
|
||||
class GuiBuildNovelDocView(QTextBrowser):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<novelWriterXML appVersion="0.6" hexVersion="0x000600f0" fileVersion="1.0" saveCount="168" autoCount="26" timeStamp="2020-05-24 18:33:34">
|
||||
<novelWriterXML appVersion="0.6.1" hexVersion="0x000601f0" fileVersion="1.0" saveCount="170" autoCount="26" timeStamp="2020-05-28 00:22:19">
|
||||
<project>
|
||||
<name>Sample Project</name>
|
||||
<title>Sample Project</title>
|
||||
@@ -20,7 +20,7 @@
|
||||
</autoReplace>
|
||||
<titleFormat>
|
||||
<title>%title%</title>
|
||||
<chapter>Chapter %chnum%: %title%</chapter>
|
||||
<chapter>Chapter %ch%: %title%</chapter>
|
||||
<unnumbered>%title%</unnumbered>
|
||||
<scene>* * *</scene>
|
||||
<section></section>
|
||||
|
||||
Reference in New Issue
Block a user