novelWriter 2.5.3__py3-none-any.whl → 2.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. {novelWriter-2.5.3.dist-info → novelWriter-2.6.dist-info}/METADATA +2 -2
  2. {novelWriter-2.5.3.dist-info → novelWriter-2.6.dist-info}/RECORD +123 -103
  3. {novelWriter-2.5.3.dist-info → novelWriter-2.6.dist-info}/WHEEL +1 -1
  4. novelwriter/__init__.py +50 -11
  5. novelwriter/assets/i18n/nw_de_DE.qm +0 -0
  6. novelwriter/assets/i18n/nw_en_US.qm +0 -0
  7. novelwriter/assets/i18n/nw_es_419.qm +0 -0
  8. novelwriter/assets/i18n/nw_fr_FR.qm +0 -0
  9. novelwriter/assets/i18n/nw_it_IT.qm +0 -0
  10. novelwriter/assets/i18n/nw_ja_JP.qm +0 -0
  11. novelwriter/assets/i18n/nw_nb_NO.qm +0 -0
  12. novelwriter/assets/i18n/nw_nl_NL.qm +0 -0
  13. novelwriter/assets/i18n/nw_pl_PL.qm +0 -0
  14. novelwriter/assets/i18n/nw_pt_BR.qm +0 -0
  15. novelwriter/assets/i18n/nw_ru_RU.qm +0 -0
  16. novelwriter/assets/i18n/nw_zh_CN.qm +0 -0
  17. novelwriter/assets/i18n/project_de_DE.json +2 -0
  18. novelwriter/assets/i18n/project_en_GB.json +1 -0
  19. novelwriter/assets/i18n/project_en_US.json +2 -0
  20. novelwriter/assets/i18n/project_it_IT.json +2 -0
  21. novelwriter/assets/i18n/project_ja_JP.json +2 -0
  22. novelwriter/assets/i18n/project_nb_NO.json +2 -0
  23. novelwriter/assets/i18n/project_nl_NL.json +2 -0
  24. novelwriter/assets/i18n/project_pl_PL.json +2 -0
  25. novelwriter/assets/i18n/project_pt_BR.json +2 -0
  26. novelwriter/assets/i18n/project_zh_CN.json +2 -0
  27. novelwriter/assets/icons/typicons_dark/icons.conf +8 -0
  28. novelwriter/assets/icons/typicons_dark/mixed_copy.svg +4 -0
  29. novelwriter/assets/icons/typicons_dark/mixed_margin-bottom.svg +6 -0
  30. novelwriter/assets/icons/typicons_dark/mixed_margin-left.svg +6 -0
  31. novelwriter/assets/icons/typicons_dark/mixed_margin-right.svg +6 -0
  32. novelwriter/assets/icons/typicons_dark/mixed_margin-top.svg +6 -0
  33. novelwriter/assets/icons/typicons_dark/mixed_size-height.svg +6 -0
  34. novelwriter/assets/icons/typicons_dark/mixed_size-width.svg +6 -0
  35. novelwriter/assets/icons/typicons_dark/nw_toolbar.svg +5 -0
  36. novelwriter/assets/icons/typicons_light/icons.conf +8 -0
  37. novelwriter/assets/icons/typicons_light/mixed_copy.svg +4 -0
  38. novelwriter/assets/icons/typicons_light/mixed_margin-bottom.svg +6 -0
  39. novelwriter/assets/icons/typicons_light/mixed_margin-left.svg +6 -0
  40. novelwriter/assets/icons/typicons_light/mixed_margin-right.svg +6 -0
  41. novelwriter/assets/icons/typicons_light/mixed_margin-top.svg +6 -0
  42. novelwriter/assets/icons/typicons_light/mixed_size-height.svg +6 -0
  43. novelwriter/assets/icons/typicons_light/mixed_size-width.svg +6 -0
  44. novelwriter/assets/icons/typicons_light/nw_toolbar.svg +5 -0
  45. novelwriter/assets/manual.pdf +0 -0
  46. novelwriter/assets/sample.zip +0 -0
  47. novelwriter/common.py +101 -3
  48. novelwriter/config.py +30 -17
  49. novelwriter/constants.py +189 -81
  50. novelwriter/core/buildsettings.py +74 -40
  51. novelwriter/core/coretools.py +146 -148
  52. novelwriter/core/docbuild.py +133 -171
  53. novelwriter/core/document.py +1 -1
  54. novelwriter/core/index.py +39 -38
  55. novelwriter/core/item.py +42 -9
  56. novelwriter/core/itemmodel.py +518 -0
  57. novelwriter/core/options.py +5 -2
  58. novelwriter/core/project.py +68 -90
  59. novelwriter/core/projectdata.py +8 -2
  60. novelwriter/core/projectxml.py +1 -1
  61. novelwriter/core/sessions.py +1 -1
  62. novelwriter/core/spellcheck.py +10 -15
  63. novelwriter/core/status.py +24 -8
  64. novelwriter/core/storage.py +1 -1
  65. novelwriter/core/tree.py +269 -288
  66. novelwriter/dialogs/about.py +1 -1
  67. novelwriter/dialogs/docmerge.py +8 -18
  68. novelwriter/dialogs/docsplit.py +1 -1
  69. novelwriter/dialogs/editlabel.py +1 -1
  70. novelwriter/dialogs/preferences.py +47 -34
  71. novelwriter/dialogs/projectsettings.py +149 -99
  72. novelwriter/dialogs/quotes.py +1 -1
  73. novelwriter/dialogs/wordlist.py +11 -10
  74. novelwriter/enum.py +37 -24
  75. novelwriter/error.py +2 -2
  76. novelwriter/extensions/configlayout.py +28 -13
  77. novelwriter/extensions/eventfilters.py +1 -1
  78. novelwriter/extensions/modified.py +30 -6
  79. novelwriter/extensions/novelselector.py +4 -3
  80. novelwriter/extensions/pagedsidebar.py +9 -9
  81. novelwriter/extensions/progressbars.py +4 -4
  82. novelwriter/extensions/statusled.py +3 -3
  83. novelwriter/extensions/switch.py +3 -3
  84. novelwriter/extensions/switchbox.py +1 -1
  85. novelwriter/extensions/versioninfo.py +1 -1
  86. novelwriter/formats/shared.py +156 -0
  87. novelwriter/formats/todocx.py +1191 -0
  88. novelwriter/formats/tohtml.py +454 -0
  89. novelwriter/{core → formats}/tokenizer.py +497 -495
  90. novelwriter/formats/tomarkdown.py +218 -0
  91. novelwriter/{core → formats}/toodt.py +312 -433
  92. novelwriter/formats/toqdoc.py +486 -0
  93. novelwriter/formats/toraw.py +91 -0
  94. novelwriter/gui/doceditor.py +347 -287
  95. novelwriter/gui/dochighlight.py +97 -85
  96. novelwriter/gui/docviewer.py +90 -33
  97. novelwriter/gui/docviewerpanel.py +18 -26
  98. novelwriter/gui/editordocument.py +18 -3
  99. novelwriter/gui/itemdetails.py +27 -29
  100. novelwriter/gui/mainmenu.py +130 -64
  101. novelwriter/gui/noveltree.py +46 -48
  102. novelwriter/gui/outline.py +202 -256
  103. novelwriter/gui/projtree.py +590 -1242
  104. novelwriter/gui/search.py +11 -19
  105. novelwriter/gui/sidebar.py +8 -7
  106. novelwriter/gui/statusbar.py +20 -3
  107. novelwriter/gui/theme.py +11 -6
  108. novelwriter/guimain.py +101 -201
  109. novelwriter/shared.py +67 -28
  110. novelwriter/text/counting.py +3 -1
  111. novelwriter/text/patterns.py +169 -61
  112. novelwriter/tools/dictionaries.py +3 -3
  113. novelwriter/tools/lipsum.py +1 -1
  114. novelwriter/tools/manusbuild.py +15 -13
  115. novelwriter/tools/manuscript.py +121 -79
  116. novelwriter/tools/manussettings.py +424 -291
  117. novelwriter/tools/noveldetails.py +1 -1
  118. novelwriter/tools/welcome.py +6 -6
  119. novelwriter/tools/writingstats.py +4 -4
  120. novelwriter/types.py +25 -9
  121. novelwriter/core/tohtml.py +0 -530
  122. novelwriter/core/tomarkdown.py +0 -252
  123. novelwriter/core/toqdoc.py +0 -419
  124. {novelWriter-2.5.3.dist-info → novelWriter-2.6.dist-info}/LICENSE.md +0 -0
  125. {novelWriter-2.5.3.dist-info → novelWriter-2.6.dist-info}/entry_points.txt +0 -0
  126. {novelWriter-2.5.3.dist-info → novelWriter-2.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,156 @@
1
+ """
2
+ novelWriter – Formats Shared
3
+ ============================
4
+
5
+ File History:
6
+ Created: 2024-10-21 [2.6b1]
7
+
8
+ This file is a part of novelWriter
9
+ Copyright (C) 2024 Veronica Berglyd Olsen and novelWriter contributors
10
+
11
+ This program is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
+ the Free Software Foundation, either version 3 of the License, or
14
+ (at your option) any later version.
15
+
16
+ This program is distributed in the hope that it will be useful, but
17
+ WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
+ General Public License for more details.
20
+
21
+ You should have received a copy of the GNU General Public License
22
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
23
+ """
24
+ from __future__ import annotations
25
+
26
+ import re
27
+
28
+ from enum import Flag, IntEnum
29
+
30
+ from PyQt5.QtGui import QColor
31
+
32
+ ESCAPES = {r"\*": "*", r"\~": "~", r"\_": "_", r"\[": "[", r"\]": "]", r"\ ": ""}
33
+ RX_ESC = re.compile("|".join([re.escape(k) for k in ESCAPES.keys()]), flags=re.DOTALL)
34
+
35
+
36
+ def stripEscape(text: str) -> str:
37
+ """Strip escaped Markdown characters from paragraph text."""
38
+ if "\\" in text:
39
+ return RX_ESC.sub(lambda x: ESCAPES[x.group(0)], text)
40
+ return text
41
+
42
+
43
+ class TextDocumentTheme:
44
+ """Default document theme."""
45
+
46
+ text: QColor = QColor(0, 0, 0)
47
+ highlight: QColor = QColor(255, 255, 166)
48
+ head: QColor = QColor(66, 113, 174)
49
+ link: QColor = QColor(66, 113, 174)
50
+ comment: QColor = QColor(100, 100, 100)
51
+ note: QColor = QColor(129, 55, 9)
52
+ code: QColor = QColor(66, 113, 174)
53
+ modifier: QColor = QColor(129, 55, 9)
54
+ keyword: QColor = QColor(245, 135, 31)
55
+ tag: QColor = QColor(66, 113, 174)
56
+ optional: QColor = QColor(66, 113, 174)
57
+ dialog: QColor = QColor(66, 113, 174)
58
+ altdialog: QColor = QColor(129, 55, 9)
59
+
60
+
61
+ # Enums
62
+ # =====
63
+
64
+ class TextFmt(IntEnum):
65
+ """Text Format.
66
+
67
+ An enum indicating the beginning or end of a text format region.
68
+ They must be paired with a position, and apply to locations in a
69
+ text block.
70
+ """
71
+
72
+ B_B = 1 # Begin bold
73
+ B_E = 2 # End bold
74
+ I_B = 3 # Begin italics
75
+ I_E = 4 # End italics
76
+ D_B = 5 # Begin strikeout
77
+ D_E = 6 # End strikeout
78
+ U_B = 7 # Begin underline
79
+ U_E = 8 # End underline
80
+ M_B = 9 # Begin mark
81
+ M_E = 10 # End mark
82
+ SUP_B = 11 # Begin superscript
83
+ SUP_E = 12 # End superscript
84
+ SUB_B = 13 # Begin subscript
85
+ SUB_E = 14 # End subscript
86
+ COL_B = 15 # Begin colour
87
+ COL_E = 16 # End colour
88
+ ANM_B = 17 # Begin anchor name
89
+ ANM_E = 18 # End anchor name
90
+ ARF_B = 19 # Begin anchor link
91
+ ARF_E = 20 # End anchor link
92
+ HRF_B = 21 # Begin href link
93
+ HRF_E = 22 # End href link
94
+ FNOTE = 23 # Footnote marker
95
+ FIELD = 24 # Data field
96
+ STRIP = 25 # Strip the format code
97
+
98
+
99
+ class BlockTyp(IntEnum):
100
+ """Text Block Type.
101
+
102
+ An enum indicating the type of a text block.
103
+ """
104
+
105
+ EMPTY = 1 # Empty line (new paragraph)
106
+ TITLE = 2 # Title
107
+ PART = 3 # Partition
108
+ HEAD1 = 4 # Heading 1 or Chapter
109
+ HEAD2 = 5 # Heading 2 or Scene
110
+ HEAD3 = 6 # Heading 3 or Section
111
+ HEAD4 = 7 # Heading 4
112
+ TEXT = 8 # Text line
113
+ SEP = 9 # Scene separator
114
+ SKIP = 10 # Paragraph break
115
+ SUMMARY = 11 # Synopsis/short comment
116
+ NOTE = 12 # Note
117
+ COMMENT = 13 # Comment
118
+ KEYWORD = 14 # Tag/reference keywords
119
+
120
+
121
+ class BlockFmt(Flag):
122
+ """Text Block Format.
123
+
124
+ An enum of flags that can be combined to format a text block.
125
+ """
126
+
127
+ NONE = 0x0000 # No special style
128
+ LEFT = 0x0001 # Left aligned
129
+ RIGHT = 0x0002 # Right aligned
130
+ CENTRE = 0x0004 # Centred
131
+ JUSTIFY = 0x0008 # Justified
132
+ PBB = 0x0010 # Page break before
133
+ PBA = 0x0020 # Page break after
134
+ Z_TOP = 0x0040 # Zero top margin
135
+ Z_BTM = 0x0080 # Zero bottom margin
136
+ IND_L = 0x0100 # Left indentation
137
+ IND_R = 0x0200 # Right indentation
138
+ IND_T = 0x0400 # Text indentation
139
+
140
+ # Masks
141
+ ALIGNED = LEFT | RIGHT | CENTRE | JUSTIFY
142
+
143
+
144
+ # Types
145
+ # =====
146
+
147
+ # A list of formats for a single text string, consisting of:
148
+ # text position, text format, and meta data
149
+ T_Formats = list[tuple[int, TextFmt, str]]
150
+
151
+ # A note or comment with text and associated text formats
152
+ T_Note = tuple[str, T_Formats]
153
+
154
+ # A tokenized text block, consisting of:
155
+ # type, header number, text, text formats, and block format
156
+ T_Block = tuple[BlockTyp, str, str, T_Formats, BlockFmt]