Add processing of story structure comments in the build tool

This commit is contained in:
Veronica Berglyd Olsen
2025-04-08 20:12:48 +02:00
parent 04be98fd59
commit c107978173
5 changed files with 19 additions and 14 deletions
@@ -3,6 +3,7 @@
"Short Description": "Short Description", "Short Description": "Short Description",
"Footnotes": "Footnotes", "Footnotes": "Footnotes",
"Comment": "Comment", "Comment": "Comment",
"Story Structure": "Story Structure",
"Notes": "Notes", "Notes": "Notes",
"Tag": "Tag", "Tag": "Tag",
"Point of View": "Point of View", "Point of View": "Point of View",
+7 -5
View File
@@ -64,12 +64,12 @@ class ComStyle(NamedTuple):
COMMENT_STYLE = { COMMENT_STYLE = {
nwComment.PLAIN: ComStyle("Comment", "comment", "comment"), nwComment.PLAIN: ComStyle("Comment", "comment", "comment"),
nwComment.IGNORE: ComStyle(), nwComment.IGNORE: ComStyle(),
nwComment.SYNOPSIS: ComStyle("Synopsis", "modifier", "synopsis"), nwComment.SYNOPSIS: ComStyle("Synopsis", "modifier", "note"),
nwComment.SHORT: ComStyle("Short Description", "modifier", "synopsis"), nwComment.SHORT: ComStyle("Short Description", "modifier", "note"),
nwComment.NOTE: ComStyle("Note", "modifier", "note"), nwComment.NOTE: ComStyle("Note", "modifier", "note"),
nwComment.FOOTNOTE: ComStyle("", "modifier", "note"), nwComment.FOOTNOTE: ComStyle("", "modifier", "note"),
nwComment.COMMENT: ComStyle(), nwComment.COMMENT: ComStyle(),
nwComment.STORY: ComStyle("", "modifier", "note"), nwComment.STORY: ComStyle("Story Structure", "modifier", "note"),
} }
HEADINGS = [ HEADINGS = [
BlockTyp.TITLE, BlockTyp.PART, BlockTyp.HEAD1, BlockTyp.TITLE, BlockTyp.PART, BlockTyp.HEAD1,
@@ -440,7 +440,7 @@ class Tokenizer(ABC):
def initDocument(self) -> None: def initDocument(self) -> None:
"""Initialise data after settings.""" """Initialise data after settings."""
self._classes["modifier"] = self._theme.modifier self._classes["modifier"] = self._theme.modifier
self._classes["synopsis"] = self._theme.note self._classes["note"] = self._theme.note
self._classes["comment"] = self._theme.comment self._classes["comment"] = self._theme.comment
self._classes["dialog"] = self._theme.dialog self._classes["dialog"] = self._theme.dialog
self._classes["altdialog"] = self._theme.altdialog self._classes["altdialog"] = self._theme.altdialog
@@ -615,7 +615,9 @@ class Tokenizer(ABC):
if doJustify and not tStyle & BlockFmt.ALIGNED: if doJustify and not tStyle & BlockFmt.ALIGNED:
tStyle |= BlockFmt.JUSTIFY tStyle |= BlockFmt.JUSTIFY
if cStyle in (nwComment.SYNOPSIS, nwComment.SHORT, nwComment.PLAIN): if cStyle in (
nwComment.SYNOPSIS, nwComment.SHORT, nwComment.PLAIN, nwComment.STORY
):
bStyle = COMMENT_STYLE[cStyle] bStyle = COMMENT_STYLE[cStyle]
tLine, tFmt = self._formatComment(bStyle, cKey, cText) tLine, tFmt = self._formatComment(bStyle, cKey, cText)
tBlocks.append(( tBlocks.append((
+4 -2
View File
@@ -1,8 +1,8 @@
%%~name: Making a Scene %%~name: Making a Scene
%%~path: 6a2d6d5f4f401/636b6aa9b697b %%~path: 6a2d6d5f4f401/636b6aa9b697b
%%~kind: NOVEL/DOCUMENT %%~kind: NOVEL/DOCUMENT
%%~hash: 8d245fa740926779d19741ff7f75ef387b55130c %%~hash: c057a5e9309b0e764c367b0fe9ab0607e3308622
%%~date: Unknown/2024-10-25 23:54:52 %%~date: Unknown/2025-04-08 20:10:33
### Making a Scene ### Making a Scene
@pov: Jane @pov: Jane
@@ -10,6 +10,8 @@
@location: Earth @location: Earth
@mention: Space @mention: Space
%Story.Resolution: You can describe the scene structure with story comments.
A scene is defined by a level three heading, like the one at the top of this page. The scene will be assigned to the chapter preceding it in the project tree. The scene document can be sorted after the chapter document, or as a child of the chapter. Both result in the same output in the end, so it is a matter of preference. A scene is defined by a level three heading, like the one at the top of this page. The scene will be assigned to the chapter preceding it in the project tree. The scene document can be sorted after the chapter document, or as a child of the chapter. Both result in the same output in the end, so it is a matter of preference.
Each paragraph in the scene is separated by a blank line. The text supports minimal formatting, like **bold**, _italic_ and **_bold italic_**. You can also ~~strike through~~ text. There is **some support for _nested_ emphasis**, but there are some known limitations. If the syntax highlighter doesnt show it correctly, the export tool will not either. Each paragraph in the scene is separated by a blank line. The text supports minimal formatting, like **bold**, _italic_ and **_bold italic_**. You can also ~~strike through~~ text. There is **some support for _nested_ emphasis**, but there are some known limitations. If the syntax highlighter doesnt show it correctly, the export tool will not either.
+3 -3
View File
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.7a3" hexVersion="0x020700a3" fileVersion="1.5" fileRevision="4" timeStamp="2025-03-23 22:26:31"> <novelWriterXML appVersion="2.7a3" hexVersion="0x020700a3" fileVersion="1.5" fileRevision="4" timeStamp="2025-04-08 20:12:28">
<project id="e2be99af-f9bf-4403-857a-c3d1ac25abea" saveCount="2166" autoCount="282" editTime="96058"> <project id="e2be99af-f9bf-4403-857a-c3d1ac25abea" saveCount="2176" autoCount="285" editTime="96579">
<name>Sample Project</name> <name>Sample Project</name>
<author>Jane Smith</author> <author>Jane Smith</author>
</project> </project>
@@ -58,7 +58,7 @@
<name status="sf24ce6" import="ia857f0" active="yes">Chapter One</name> <name status="sf24ce6" import="ia857f0" active="yes">Chapter One</name>
</item> </item>
<item handle="636b6aa9b697b" parent="6a2d6d5f4f401" root="7031beac91f75" order="0" type="FILE" class="NOVEL" layout="DOCUMENT"> <item handle="636b6aa9b697b" parent="6a2d6d5f4f401" root="7031beac91f75" order="0" type="FILE" class="NOVEL" layout="DOCUMENT">
<meta expanded="no" heading="H3" charCount="2999" wordCount="530" paraCount="16" cursorPos="1035" /> <meta expanded="no" heading="H3" charCount="2999" wordCount="530" paraCount="16" cursorPos="159" />
<name status="s90e6c9" import="ia857f0" active="yes">Making a Scene</name> <name status="s90e6c9" import="ia857f0" active="yes">Making a Scene</name>
</item> </item>
<item handle="bc0cbd2a407f3" parent="6a2d6d5f4f401" root="7031beac91f75" order="1" type="FILE" class="NOVEL" layout="DOCUMENT"> <item handle="bc0cbd2a407f3" parent="6a2d6d5f4f401" root="7031beac91f75" order="1" type="FILE" class="NOVEL" layout="DOCUMENT">
+4 -4
View File
@@ -785,7 +785,7 @@ def testFmtToken_MetaFormat(mockGUI):
BlockTyp.COMMENT, "", "Synopsis: The synopsis", [ BlockTyp.COMMENT, "", "Synopsis: The synopsis", [
(0, TextFmt.B_B, ""), (0, TextFmt.COL_B, "modifier"), (0, TextFmt.B_B, ""), (0, TextFmt.COL_B, "modifier"),
(9, TextFmt.COL_E, ""), (9, TextFmt.B_E, ""), (9, TextFmt.COL_E, ""), (9, TextFmt.B_E, ""),
(10, TextFmt.COL_B, "synopsis"), (22, TextFmt.COL_E, "") (10, TextFmt.COL_B, "note"), (22, TextFmt.COL_E, "")
], BlockFmt.NONE ], BlockFmt.NONE
)] )]
@@ -802,7 +802,7 @@ def testFmtToken_MetaFormat(mockGUI):
BlockTyp.COMMENT, "", "Short Description: A short description", [ BlockTyp.COMMENT, "", "Short Description: A short description", [
(0, TextFmt.B_B, ""), (0, TextFmt.COL_B, "modifier"), (0, TextFmt.B_B, ""), (0, TextFmt.COL_B, "modifier"),
(18, TextFmt.COL_E, ""), (18, TextFmt.B_E, ""), (18, TextFmt.COL_E, ""), (18, TextFmt.B_E, ""),
(19, TextFmt.COL_B, "synopsis"), (38, TextFmt.COL_E, ""), (19, TextFmt.COL_B, "note"), (38, TextFmt.COL_E, ""),
], BlockFmt.NONE ], BlockFmt.NONE
)] )]
@@ -1553,7 +1553,7 @@ def testFmtToken_TextIndent(mockGUI):
tokens.tokenizeText() tokens.tokenizeText()
tFmt = [ tFmt = [
(0, TextFmt.B_B, ""), (0, TextFmt.COL_B, "modifier"), (9, TextFmt.COL_E, ""), (0, TextFmt.B_B, ""), (0, TextFmt.COL_B, "modifier"), (9, TextFmt.COL_E, ""),
(9, TextFmt.B_E, ""), (10, TextFmt.COL_B, "synopsis"), (24, TextFmt.COL_E, ""), (9, TextFmt.B_E, ""), (10, TextFmt.COL_B, "note"), (24, TextFmt.COL_E, ""),
] ]
assert tokens._blocks == [ assert tokens._blocks == [
(BlockTyp.HEAD3, TM1, "Scene Two", [], BlockFmt.NONE), (BlockTyp.HEAD3, TM1, "Scene Two", [], BlockFmt.NONE),
@@ -1814,7 +1814,7 @@ def testFmtToken_FormatComment(mockGUI):
"Synopsis: Hello world!", [ "Synopsis: Hello world!", [
(0, TextFmt.B_B, ""), (0, TextFmt.COL_B, "modifier"), (0, TextFmt.B_B, ""), (0, TextFmt.COL_B, "modifier"),
(9, TextFmt.COL_E, ""), (9, TextFmt.B_E, ""), (9, TextFmt.COL_E, ""), (9, TextFmt.B_E, ""),
(10, TextFmt.COL_B, "synopsis"), (22, TextFmt.COL_E, ""), (10, TextFmt.COL_B, "note"), (22, TextFmt.COL_E, ""),
] ]
) )