Add hard scene break formatting
This commit is contained in:
@@ -56,8 +56,10 @@ SETTINGS_TEMPLATE = {
|
||||
"headings.fmtChapter": (str, nwHeadFmt.TITLE),
|
||||
"headings.fmtUnnumbered": (str, nwHeadFmt.TITLE),
|
||||
"headings.fmtScene": (str, "* * *"),
|
||||
"headings.fmtHardScene": (str, ""),
|
||||
"headings.fmtSection": (str, ""),
|
||||
"headings.hideScene": (bool, False),
|
||||
"headings.hideHardScene": (bool, False),
|
||||
"headings.hideSection": (bool, True),
|
||||
"headings.centerTitle": (bool, True),
|
||||
"headings.centerChapter": (bool, False),
|
||||
@@ -104,8 +106,10 @@ SETTINGS_LABELS = {
|
||||
"headings.fmtChapter": QT_TRANSLATE_NOOP("Builds", "Chapter Headings"),
|
||||
"headings.fmtUnnumbered": QT_TRANSLATE_NOOP("Builds", "Unnumbered Headings"),
|
||||
"headings.fmtScene": QT_TRANSLATE_NOOP("Builds", "Scene Headings"),
|
||||
"headings.fmtHardScene": QT_TRANSLATE_NOOP("Builds", "Hard Scene Headings"),
|
||||
"headings.fmtSection": QT_TRANSLATE_NOOP("Builds", "Section Headings"),
|
||||
"headings.hideScene": QT_TRANSLATE_NOOP("Builds", "Hide Scene Headings"),
|
||||
"headings.hideHardScene": QT_TRANSLATE_NOOP("Builds", "Hide Hard Scene Headings"),
|
||||
"headings.hideSection": QT_TRANSLATE_NOOP("Builds", "Hide Section Headings"),
|
||||
|
||||
"text.grpContent": QT_TRANSLATE_NOOP("Builds", "Text Content"),
|
||||
|
||||
@@ -282,6 +282,10 @@ class NWBuildDocument:
|
||||
self._build.getStr("headings.fmtScene"),
|
||||
self._build.getBool("headings.hideScene")
|
||||
)
|
||||
bldObj.setHardSceneFormat(
|
||||
self._build.getStr("headings.fmtHardScene"),
|
||||
self._build.getBool("headings.hideHardScene")
|
||||
)
|
||||
bldObj.setSectionFormat(
|
||||
self._build.getStr("headings.fmtSection"),
|
||||
self._build.getBool("headings.hideSection")
|
||||
|
||||
@@ -156,9 +156,11 @@ class Tokenizer(ABC):
|
||||
self._fmtChapter = nwHeadFmt.TITLE # Formatting for numbered chapters
|
||||
self._fmtUnNum = nwHeadFmt.TITLE # Formatting for unnumbered chapters
|
||||
self._fmtScene = nwHeadFmt.TITLE # Formatting for scenes
|
||||
self._fmtHScene = nwHeadFmt.TITLE # Formatting for hard scenes
|
||||
self._fmtSection = nwHeadFmt.TITLE # Formatting for sections
|
||||
|
||||
self._hideScene = False # Do not include scene headings
|
||||
self._hideHScene = False # Do not include hard scene headings
|
||||
self._hideSection = False # Do not include section headings
|
||||
|
||||
self._linkHeaders = False # Add an anchor before headings
|
||||
@@ -254,6 +256,12 @@ class Tokenizer(ABC):
|
||||
self._hideScene = hide
|
||||
return
|
||||
|
||||
def setHardSceneFormat(self, hFormat: str, hide: bool) -> None:
|
||||
"""Set the hard scene format pattern and hidden status."""
|
||||
self._fmtHScene = hFormat.strip()
|
||||
self._hideHScene = hide
|
||||
return
|
||||
|
||||
def setSectionFormat(self, hFormat: str, hide: bool) -> None:
|
||||
"""Set the section format pattern and hidden status."""
|
||||
self._fmtSection = hFormat.strip()
|
||||
@@ -603,7 +611,7 @@ class Tokenizer(ABC):
|
||||
if self._keepMarkdown:
|
||||
tmpMarkdown.append(f"{aLine}\n")
|
||||
|
||||
elif aLine[:4] == "### ":
|
||||
elif aLine[:4] == "### " or aLine[:5] == "###! ":
|
||||
# Scene Headings
|
||||
# ==============
|
||||
# Scene headings in novel documents are treated as centred
|
||||
@@ -619,12 +627,15 @@ class Tokenizer(ABC):
|
||||
tText = aLine[4:].strip()
|
||||
tType = self.T_HEAD3
|
||||
tStyle = self.A_NONE
|
||||
isHard = aLine[:5] == "###! "
|
||||
sHide = self._hideHScene if isHard else self._hideScene
|
||||
fScene = self._fmtHScene if isHard else self._fmtScene
|
||||
if self._isNovel:
|
||||
self._hFormatter.incScene()
|
||||
tText = self._hFormatter.apply(self._fmtScene, tText, nHead)
|
||||
tText = self._hFormatter.apply(fScene, tText, nHead)
|
||||
tStyle = self._sceneStyle
|
||||
if tText == "":
|
||||
tType = self.T_EMPTY if self._noSep or self._hideScene else self.T_SKIP
|
||||
tType = self.T_EMPTY if self._noSep or sHide else self.T_SKIP
|
||||
tStyle = self.A_NONE
|
||||
elif tText == self._fmtScene:
|
||||
tText = "" if self._noSep else tText
|
||||
|
||||
Reference in New Issue
Block a user