novelWriter 2.5.2__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.
- {novelWriter-2.5.2.dist-info → novelWriter-2.6.dist-info}/METADATA +5 -4
- {novelWriter-2.5.2.dist-info → novelWriter-2.6.dist-info}/RECORD +126 -105
- {novelWriter-2.5.2.dist-info → novelWriter-2.6.dist-info}/WHEEL +1 -1
- novelwriter/__init__.py +50 -11
- novelwriter/assets/i18n/nw_de_DE.qm +0 -0
- novelwriter/assets/i18n/nw_en_US.qm +0 -0
- novelwriter/assets/i18n/nw_es_419.qm +0 -0
- novelwriter/assets/i18n/nw_fr_FR.qm +0 -0
- novelwriter/assets/i18n/nw_it_IT.qm +0 -0
- novelwriter/assets/i18n/nw_ja_JP.qm +0 -0
- novelwriter/assets/i18n/nw_nb_NO.qm +0 -0
- novelwriter/assets/i18n/nw_nl_NL.qm +0 -0
- novelwriter/assets/i18n/nw_pl_PL.qm +0 -0
- novelwriter/assets/i18n/nw_pt_BR.qm +0 -0
- novelwriter/assets/i18n/nw_ru_RU.qm +0 -0
- novelwriter/assets/i18n/nw_zh_CN.qm +0 -0
- novelwriter/assets/i18n/project_de_DE.json +4 -2
- novelwriter/assets/i18n/project_en_GB.json +1 -0
- novelwriter/assets/i18n/project_en_US.json +2 -0
- novelwriter/assets/i18n/project_it_IT.json +2 -0
- novelwriter/assets/i18n/project_ja_JP.json +2 -0
- novelwriter/assets/i18n/project_nb_NO.json +2 -0
- novelwriter/assets/i18n/project_nl_NL.json +2 -0
- novelwriter/assets/i18n/project_pl_PL.json +2 -0
- novelwriter/assets/i18n/project_pt_BR.json +2 -0
- novelwriter/assets/i18n/project_ru_RU.json +11 -0
- novelwriter/assets/i18n/project_zh_CN.json +2 -0
- novelwriter/assets/icons/typicons_dark/icons.conf +8 -0
- novelwriter/assets/icons/typicons_dark/mixed_copy.svg +4 -0
- novelwriter/assets/icons/typicons_dark/mixed_margin-bottom.svg +6 -0
- novelwriter/assets/icons/typicons_dark/mixed_margin-left.svg +6 -0
- novelwriter/assets/icons/typicons_dark/mixed_margin-right.svg +6 -0
- novelwriter/assets/icons/typicons_dark/mixed_margin-top.svg +6 -0
- novelwriter/assets/icons/typicons_dark/mixed_size-height.svg +6 -0
- novelwriter/assets/icons/typicons_dark/mixed_size-width.svg +6 -0
- novelwriter/assets/icons/typicons_dark/nw_toolbar.svg +5 -0
- novelwriter/assets/icons/typicons_light/icons.conf +8 -0
- novelwriter/assets/icons/typicons_light/mixed_copy.svg +4 -0
- novelwriter/assets/icons/typicons_light/mixed_margin-bottom.svg +6 -0
- novelwriter/assets/icons/typicons_light/mixed_margin-left.svg +6 -0
- novelwriter/assets/icons/typicons_light/mixed_margin-right.svg +6 -0
- novelwriter/assets/icons/typicons_light/mixed_margin-top.svg +6 -0
- novelwriter/assets/icons/typicons_light/mixed_size-height.svg +6 -0
- novelwriter/assets/icons/typicons_light/mixed_size-width.svg +6 -0
- novelwriter/assets/icons/typicons_light/nw_toolbar.svg +5 -0
- novelwriter/assets/manual.pdf +0 -0
- novelwriter/assets/sample.zip +0 -0
- novelwriter/assets/text/credits_en.htm +1 -0
- novelwriter/assets/themes/default_light.conf +2 -2
- novelwriter/common.py +101 -3
- novelwriter/config.py +30 -17
- novelwriter/constants.py +189 -81
- novelwriter/core/buildsettings.py +74 -40
- novelwriter/core/coretools.py +146 -148
- novelwriter/core/docbuild.py +133 -171
- novelwriter/core/document.py +1 -1
- novelwriter/core/index.py +39 -38
- novelwriter/core/item.py +42 -9
- novelwriter/core/itemmodel.py +518 -0
- novelwriter/core/options.py +5 -2
- novelwriter/core/project.py +68 -90
- novelwriter/core/projectdata.py +8 -2
- novelwriter/core/projectxml.py +1 -1
- novelwriter/core/sessions.py +1 -1
- novelwriter/core/spellcheck.py +10 -15
- novelwriter/core/status.py +24 -8
- novelwriter/core/storage.py +1 -1
- novelwriter/core/tree.py +269 -288
- novelwriter/dialogs/about.py +1 -1
- novelwriter/dialogs/docmerge.py +8 -18
- novelwriter/dialogs/docsplit.py +1 -1
- novelwriter/dialogs/editlabel.py +1 -1
- novelwriter/dialogs/preferences.py +47 -34
- novelwriter/dialogs/projectsettings.py +149 -99
- novelwriter/dialogs/quotes.py +1 -1
- novelwriter/dialogs/wordlist.py +11 -10
- novelwriter/enum.py +37 -24
- novelwriter/error.py +2 -2
- novelwriter/extensions/configlayout.py +28 -13
- novelwriter/extensions/eventfilters.py +1 -1
- novelwriter/extensions/modified.py +30 -6
- novelwriter/extensions/novelselector.py +4 -3
- novelwriter/extensions/pagedsidebar.py +9 -9
- novelwriter/extensions/progressbars.py +4 -4
- novelwriter/extensions/statusled.py +3 -3
- novelwriter/extensions/switch.py +3 -3
- novelwriter/extensions/switchbox.py +1 -1
- novelwriter/extensions/versioninfo.py +1 -1
- novelwriter/formats/shared.py +156 -0
- novelwriter/formats/todocx.py +1191 -0
- novelwriter/formats/tohtml.py +454 -0
- novelwriter/{core → formats}/tokenizer.py +497 -495
- novelwriter/formats/tomarkdown.py +218 -0
- novelwriter/{core → formats}/toodt.py +312 -433
- novelwriter/formats/toqdoc.py +486 -0
- novelwriter/formats/toraw.py +91 -0
- novelwriter/gui/doceditor.py +347 -287
- novelwriter/gui/dochighlight.py +97 -85
- novelwriter/gui/docviewer.py +90 -33
- novelwriter/gui/docviewerpanel.py +18 -26
- novelwriter/gui/editordocument.py +18 -3
- novelwriter/gui/itemdetails.py +27 -29
- novelwriter/gui/mainmenu.py +130 -64
- novelwriter/gui/noveltree.py +46 -48
- novelwriter/gui/outline.py +202 -256
- novelwriter/gui/projtree.py +590 -1238
- novelwriter/gui/search.py +11 -19
- novelwriter/gui/sidebar.py +8 -7
- novelwriter/gui/statusbar.py +20 -3
- novelwriter/gui/theme.py +11 -6
- novelwriter/guimain.py +101 -201
- novelwriter/shared.py +67 -28
- novelwriter/text/counting.py +3 -1
- novelwriter/text/patterns.py +169 -61
- novelwriter/tools/dictionaries.py +3 -3
- novelwriter/tools/lipsum.py +1 -1
- novelwriter/tools/manusbuild.py +15 -13
- novelwriter/tools/manuscript.py +121 -79
- novelwriter/tools/manussettings.py +424 -291
- novelwriter/tools/noveldetails.py +1 -1
- novelwriter/tools/welcome.py +6 -6
- novelwriter/tools/writingstats.py +4 -4
- novelwriter/types.py +25 -9
- novelwriter/core/tohtml.py +0 -530
- novelwriter/core/tomarkdown.py +0 -252
- novelwriter/core/toqdoc.py +0 -419
- {novelWriter-2.5.2.dist-info → novelWriter-2.6.dist-info}/LICENSE.md +0 -0
- {novelWriter-2.5.2.dist-info → novelWriter-2.6.dist-info}/entry_points.txt +0 -0
- {novelWriter-2.5.2.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]
|