Compare commits

...

56 Commits
v2.7 ... v2.7.3

Author SHA1 Message Date
Veronica Berglyd Olsen
2e8ee9dadf Release 2.7.3 (#2458) 2025-07-07 17:25:26 +02:00
Veronica Berglyd Olsen
0b8d613044 Update changelog notes 2025-07-07 17:16:11 +02:00
Veronica Berglyd Olsen
64b0896eaf Bump version and update changelog 2025-07-07 17:14:51 +02:00
Veronica Berglyd Olsen
cd5151be94 Update license info 2025-07-07 17:04:53 +02:00
Veronica Berglyd Olsen
367bb2e5ed Improve dialogue highlighting settings (#2457) 2025-07-06 18:27:26 +02:00
Veronica Berglyd Olsen
a748a69de3 Remove redundant string compact implementation 2025-07-06 18:24:05 +02:00
Veronica Berglyd Olsen
ec9e478399 Improve dialogue line symbol setting box (#2453) 2025-07-06 18:20:13 +02:00
Veronica Berglyd Olsen
dadc7edbd9 Move the open ended dialogue setting in Preferences (#2454) 2025-07-06 18:14:33 +02:00
Veronica Berglyd Olsen
e41f6a5fb3 Fix ConfigParser interpolation (#2456) 2025-07-06 17:35:18 +02:00
Veronica Berglyd Olsen
3149e7ec0d Disable config parser interpolation with % (#2455) 2025-07-06 17:29:19 +02:00
Veronica Berglyd Olsen
5ee362dcf4 Revert license field (#2435) 2025-06-25 10:28:05 +02:00
Veronica Berglyd Olsen
453502e1c7 Revert the format of the license field in the pyrproject file (#2434) 2025-06-25 10:23:00 +02:00
Veronica Berglyd Olsen
da3383a67c Release 2.7.2 (#2430) 2025-06-24 16:43:34 +02:00
Veronica Berglyd Olsen
4dd2d63d9b Update changelog 2025-06-24 16:40:25 +02:00
Veronica Berglyd Olsen
b16783143f Bump version to 2.7.2 and update changelog 2025-06-24 16:37:50 +02:00
Veronica Berglyd Olsen
590c66d1eb Fix missing tag display in outline (#2429) 2025-06-24 16:23:15 +02:00
Veronica Berglyd Olsen
b4db960e68 Add scene tag to sample main scene 2025-06-24 16:16:15 +02:00
Veronica Berglyd Olsen
aaf4ede04d Update test coverage 2025-06-24 16:15:49 +02:00
Veronica Berglyd Olsen
5ae385ec02 Add tag to reference by keyword lookup 2025-06-24 16:15:35 +02:00
Veronica Berglyd Olsen
ad2288e2fc Add tag value for novel docs in Outline and Novel View (#2428) 2025-06-24 16:05:59 +02:00
Veronica Berglyd Olsen
4b5f3c8af8 Clarify text alignment and break behaviour (#2427) 2025-06-24 09:07:40 +02:00
Veronica Berglyd Olsen
c1dd2ebb92 Fix typos and inconsistencies 2025-06-24 00:22:35 +02:00
Veronica Berglyd Olsen
a210a665fb Update documentation 2025-06-24 00:08:08 +02:00
Veronica Berglyd Olsen
979a55d24a Add alignment precedence test to HTML tests 2025-06-24 00:07:55 +02:00
Veronica Berglyd Olsen
3c474987b2 Check indent and justify after lines are combined in tokenizer, not before (#2426) 2025-06-23 23:24:20 +02:00
Veronica Berglyd Olsen
0bbe29bc2e Fix comments visibility (#2420) 2025-06-19 20:27:36 +02:00
Veronica Berglyd Olsen
e690243fc3 Show notes and story structure comments in the viewer 2025-06-19 20:21:19 +02:00
Veronica Berglyd Olsen
74862969e1 Fix page breaks in PDFs (#2416) 2025-06-18 20:21:09 +02:00
Veronica Berglyd Olsen
92ef020342 Display headings with a line break on a single line 2025-06-18 19:26:41 +02:00
Veronica Berglyd Olsen
2176dd2020 Only add page break before first line of a heading in PDF and preview (#2415) 2025-06-18 19:25:39 +02:00
Veronica Berglyd Olsen
2ec943d118 Fix escape characters in document formats (#2411) 2025-06-16 19:00:51 +02:00
Veronica Berglyd Olsen
01733bdbaa Use dict comprehension in auto replace processing 2025-06-16 18:58:07 +02:00
Veronica Berglyd Olsen
5bc39d29eb Process escapes in docx and qdoc classes (#2410) 2025-06-16 18:50:21 +02:00
Veronica Berglyd Olsen
8c38bece3a Update license setting in pyproject.toml 2025-06-10 00:09:04 +02:00
Veronica Berglyd Olsen
d61329a4f3 Improve build code 2025-06-10 00:08:48 +02:00
Veronica Berglyd Olsen
635493f1c1 Post release updates and AppImage fix 2025-06-09 23:42:34 +02:00
Veronica Berglyd Olsen
364b7bcf99 Release 2.7.1 (#2393) 2025-06-09 23:11:23 +02:00
Veronica Berglyd Olsen
7d53c4a06b Extend changelog and fix release date 2025-06-09 23:08:09 +02:00
Veronica Berglyd Olsen
e3981aad60 Update changelog 2025-06-09 23:06:14 +02:00
Veronica Berglyd Olsen
f08078bd08 Update Czech translation 2025-06-09 23:00:41 +02:00
Veronica Berglyd Olsen
5d1e781d20 Bump version to 2.7.1 2025-06-09 22:57:33 +02:00
Veronica Berglyd Olsen
d1d5116536 Update the AppImage build scripts (#2392) 2025-06-09 22:52:17 +02:00
Veronica Berglyd Olsen
6379f031c2 Prune the AppImage a little, and prune Windows installer less 2025-06-09 22:49:00 +02:00
Veronica Berglyd Olsen
d153d80595 Use lower case for release names 2025-06-09 22:01:22 +02:00
Veronica Berglyd Olsen
28c45719e2 Move libxcb-cursor 2025-06-09 19:36:39 +02:00
Veronica Berglyd Olsen
e6befda146 Use env var for appimagetool 2025-06-09 19:08:19 +02:00
Veronica Berglyd Olsen
910723bbcd Add symlink 2025-06-09 19:02:53 +02:00
Veronica Berglyd Olsen
a534e30467 Add the appimagetool exec 2025-06-09 18:51:49 +02:00
Veronica Berglyd Olsen
dd7c8162ac Update appimage build 2025-06-09 18:38:53 +02:00
Veronica Berglyd Olsen
2bffa83d62 Update app description 2025-06-09 15:46:17 +02:00
Veronica Berglyd Olsen
01514a94e1 Fix tag and auto-complete bugs (#2389) 2025-06-06 19:23:49 +02:00
Veronica Berglyd Olsen
53355dbcc6 Don't remove tags for the tag keyword (#2386) 2025-06-06 19:16:59 +02:00
Veronica Berglyd Olsen
bf1067a346 Make sure project items in inactive classes are removed from the index (#2387) 2025-06-06 19:07:32 +02:00
Veronica Berglyd Olsen
53784b310e Close instead of hide auto-complete menu when inactive (#2386) 2025-06-06 18:39:21 +02:00
Veronica Berglyd Olsen
f6214ae36d Build AppImage with Python 3.11 again 2025-06-03 19:53:00 +02:00
Veronica Berglyd Olsen
7aea5eb5af Add setuptools to appimage build 2025-06-01 12:42:02 +02:00
56 changed files with 2868 additions and 2306 deletions

View File

@@ -8,10 +8,13 @@ jobs:
buildLinux-AppImage:
needs: buildAssets
runs-on: ubuntu-latest
# Needs to stay on 22.04 as long as we're using manylinux_2_28
# as libxcb-cursor0 in 22.04 supports glibc >= 2.17
runs-on: ubuntu-22.04
env:
PYTHON_VERSION: "3.13"
LINUX_TAG: "manylinux_2_28_x86_64"
LINUX_TAG: "manylinux_2_28"
LINUX_ARCH: "x86_64"
steps:
- name: Python Setup
uses: actions/setup-python@v5
@@ -19,8 +22,13 @@ jobs:
python-version: "3.13"
architecture: x64
- name: Install Packages (apt)
run: |
sudo apt update
sudo apt install libxcb-cursor0
- name: Install Packages (pip)
run: pip install python-appimage
run: pip install python-appimage setuptools
- name: Checkout Source
uses: actions/checkout@v4
@@ -34,8 +42,11 @@ jobs:
- name: Build AppImage
id: build
run: |
wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$LINUX_ARCH.AppImage
chmod +x appimagetool-$LINUX_ARCH.AppImage
export APPIMAGE_TOOL_EXEC="$(pwd)/appimagetool-$LINUX_ARCH.AppImage"
echo "BUILD_VERSION=$(python pkgutils.py version)" >> $GITHUB_OUTPUT
python pkgutils.py build-appimage --linux-tag $LINUX_TAG --python-version $PYTHON_VERSION
python pkgutils.py build-appimage $LINUX_TAG $LINUX_ARCH $PYTHON_VERSION
- name: Upload Artifacts
uses: actions/upload-artifact@v4

View File

@@ -1,5 +1,108 @@
# novelWriter Changelog
## Version 2.7.3 [2025-07-07]
### Release Notes
This is a patch release that fixes a bug in, and makes a few improvement to, Preferences.
### Detailed Changelog
**Bugfixes**
* Fixes an issue where novelWriter would crash if a `%` was added to any of the free text settings
fields in Preferences. Issue #2455. PR #2456.
**Improvements**
* The "Dialogue line symbols" setting in Preferences now has an "Add" button with a dropdown menu
for all the symbols allowed in this field. Since virtually none of them are available on a
regular keyboard, this makes it easier to add them and more transparent which symbols are allowed
in the box. Issue #2453. PR #2457.
* The switch for the "Allow open-ended dialogue" setting in Preferences has been moved up one line
so it is clearer that it only applies to quoted dialogue, and not to the alternative dialogue
settings. Issue #2454. PR #2457.
**Packaging**
* Package license information has been updated to also list the licenses for the new icon themes.
Issue #2434. PRs #2435 and #2458.
----
## Version 2.7.2 [2025-06-24]
### Release Notes
This is a patch release that fixes several issues related to DocX and PDF manuscript documents,
improves how line breaks, alignment and indentation is processed, and fixes some issues with
displaying tags for novel documents on the user interface.
### Detailed Changelog
**Bugfixes**
* Fixed an issue where escaped markup characters were not replaced properly in DocX and PDF
documents, and in previews. Issue #2410. PR #2411.
* Fixed an issue where titles with line breaks in them would have page breaks applied to both lines
for preview and PDF documents. Issue #2415. PR #2416.
* Fixed an issue where the justified text setting would not be properly applied to a paragraph in a
manuscript document if there was a line break in the paragraph, but single line breaks were set
to be ignored. Issue #2426. PR #2427.
* Fixed an issue where the "Tag" field of the Outline View details panel remained blank even if a
tag was set for the novel document. Issue #2428. PR #2429.
**Improvements**
* When comments are enabled in the viewer, story comments should also be visible. A separate filter
button will be added for this in 2.8. PR #2420.
* When a paragraph has line breaks in it, the alignment tag will now override first line
indentation even if the alignment tag is not on the first line. This is more consistent with the
alignment behaviour for multi-line paragraphs in general. Issue #2425. PR #2427.
* Tags will now be shown in the Novel View tooltip pop-out under the triangle button, together with
all the other meta data collected about a document or heading. PR #2429.
**Documentation**
* The documentation on how alignment and first line indentation works in conjunction with
in-paragraph line breaks, the setting to keep or ignore such line breaks, and the forced line
break shortcode, has been improved. Issue #2425. PR #2427.
----
## Version 2.7.1 [2025-06-09]
### Release Notes
This is a patch release that fixes some issues with tags and references, an issue with the
auto-complete menu on Windows, and some issues with the AppImage on Linux. The Czech translation
for 2.7 has also been completed.
### Detailed Changelog
**Bugfixes**
* Fix a bug where tags would be listed in the auto-complete menu for mentions even if the file
defining it had been moved to Archive or Trash. Issue #2387. PR #2389.
* Fixed a bug that seems to only have occurred on Windows where the auto-complete menu would hold
on to the return and arrow keys even when it was hidden. Issue #2386. PR #2389.
**Improvements**
* The auto-complete menu in the editor no longer shows any suggestions when defining the tag.
This never made sense anyway. PR #2389.
**Internationalisation**
* Updated the Czech. PR #2393.
**Packaging**
* Fixed an issue with the AppImage release where on some platforms `libxcb-cursor0` was missing.
The library is now included in the AppImage. Issue #2374. PR #2392.
----
## Version 2.7 [2025-06-01]
### Release Notes

View File

@@ -56,6 +56,20 @@ activated by clicking the left-most icon button in the editor header.
.. versionadded:: 2.2
.. _docs_usage_formatting_shortcodes_break:
Forced Line Break
-----------------
Inserting ``[br]`` in the text will ensure a line break is always inserted in that place, even if
you turn off **Preserve Hard Line Breaks** in your manuscript build settings.
You can add a manual line break after it too, for a better visual representation in the editor, but
keep in mind that this line break is removed before the text is processed, so the text on either
side of the ``[br]`` shortcode will be considered as belonging to the same line. This can affect
how alignment is treated. See :ref:`docs_usage_align_indent_forced` for more details.
.. _docs_usage_formatting_breaks:
Vertical Space and Page Breaks

View File

@@ -53,18 +53,33 @@ the entire paragraph. For the following text, all lines will be centred:
.. code-block:: md
>> I am the very model of a modern Major-General
>> I am the very model of a modern Major-General <<
I've information vegetable, animal, and mineral
I know the kings of England, and I quote the fights historical
From Marathon to Waterloo, in order categorical <<
From Marathon to Waterloo, in order categorical
If you have multiple conflicting alignments on a paragraph, only one is applied. The order of
precedence is:
#. Left alignment
#. Right alignment
#. Centred text
#. Justified text
.. note::
It is strongly recommended that you keep the **Preserve Hard Line Breaks** setting enabled in
your manuscript build settings. This setting assumes all single line breaks in your text are
intended. Turning this off makes adding line breaks more complicated, but it is still possible.
See :ref:`docs_usage_align_indent_forced`.
Alignment with First Line Indent
================================
If you have first line indent enabled in your manuscript build settings, you probably want to
disable it for text in verses. Adding any alignment tags will cause the first line indent to be
switched off for that paragraph.
disable it for text in verses. Adding any alignment tags on a paragraph will cause the first
line indent to be switched off for that paragraph.
:bdg-info:`Example`
@@ -76,3 +91,35 @@ The following text will always be aligned against the left margin:
I've information vegetable, animal, and mineral
I know the kings of England, and I quote the fights historical
From Marathon to Waterloo, in order categorical
.. _docs_usage_align_indent_forced:
Alignment with Forced Line Breaks
=================================
If you turn off **Preserve Hard Line Breaks** in your manuscript build settings, you can still
force line breaks in paragraphs using the ``[br]`` shortcode. For clarity in the text, you can add
a line break after it as well. It doesn't result in two line breaks.
Keep in mind that when the text is processed, the lines on either side of a ``[br]`` shortcode are
combined, and any trailing hard line break is *ignored*. This means that when such a paragraph is
processed, these line breaks count as the same line. This affects how alignment tags are handled.
For instance, this text becomes centred instead of left aligned.
.. code-block:: md
>> I am the very model of a modern Major-General[br]
I've information vegetable, animal, and mineral[br]
I know the kings of England, and I quote the fights historical[br]
From Marathon to Waterloo, in order categorical <<
Since this is understood as one line, this is the only way you can actually centre this paragraph.
.. caution::
Due to this difference in how text with ``[br]`` tags are processed, it is generally better to
stick with the **Preserve Hard Line Breaks** setting enabled. It ensures a better correspondence
between what you see in the editor and what output you get.
See also :ref:`docs_usage_formatting_shortcodes_break`.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -49,9 +49,9 @@ __license__ = "GPLv3"
__author__ = "Veronica Berglyd Olsen"
__maintainer__ = "Veronica Berglyd Olsen"
__email__ = "code@vkbo.net"
__version__ = "2.7"
__hexversion__ = "0x020700f0"
__date__ = "2025-06-01"
__version__ = "2.7.3"
__hexversion__ = "0x020703f0"
__date__ = "2025-07-07"
__status__ = "Stable"
__domain__ = "novelwriter.io"

View File

@@ -3,6 +3,8 @@
"Short Description": "Krátký popis",
"Footnotes": "Poznámky pod čarou",
"Comment": "Komentář",
"Story Structure": "Struktura příběhu",
"Note": "Poznámka",
"Notes": "Poznámka",
"Tag": "Štítek",
"Point of View": "Úhel pohledu",

View File

@@ -680,11 +680,12 @@ class NWConfigParser(ConfigParser):
"""Common: Adapted Config Parser
This is a subclass of the standard config parser that adds type safe
helper functions, and support for lists.
helper functions, and support for lists. It also turns off
interpolation, which would require % symbols to be escaped (#2455).
"""
def __init__(self) -> None:
super().__init__()
super().__init__(interpolation=None)
return
def rdStr(self, section: str, option: str, default: str) -> str:

View File

@@ -44,7 +44,7 @@ from novelwriter.common import (
NWConfigParser, checkInt, checkPath, describeFont, fontMatcher,
formatTimeStamp, processDialogSymbols, simplified
)
from novelwriter.constants import nwFiles, nwHtmlUnicode, nwQuotes, nwUnicode
from novelwriter.constants import nwFiles, nwQuotes, nwUnicode
from novelwriter.error import formatException, logException
if TYPE_CHECKING:
@@ -892,7 +892,7 @@ class Config:
"""
self.splashMessage(f"Initialising {kind} font: {font.family()}")
metrics = QFontMetrics(font)
for char in nwHtmlUnicode.U_TO_H.keys():
for char in nwUnicode.UI_SYMBOLS:
if not metrics.inFont(char): # type: ignore
logger.warning("No glyph U+%04x in font", ord(char)) # pragma: no cover
return

View File

@@ -184,6 +184,10 @@ class nwKeyWords:
POV_KEY, FOCUS_KEY, CHAR_KEY, PLOT_KEY, TIME_KEY, WORLD_KEY,
OBJECT_KEY, ENTITY_KEY, CUSTOM_KEY,
]
CAN_LOOKUP: Final[list[str]] = [
POV_KEY, FOCUS_KEY, CHAR_KEY, PLOT_KEY, TIME_KEY, WORLD_KEY,
OBJECT_KEY, ENTITY_KEY, CUSTOM_KEY, STORY_KEY, MENTION_KEY,
]
# Set of Valid Keys
VALID_KEYS: Final[set[str]] = set(ALL_KEYS)
@@ -582,21 +586,14 @@ class nwUnicode:
U_TIMES = "\u00d7" # Multiplication sign
U_DIVIDE = "\u00f7" # Division sign
# Arrows
U_UTRI = "\u25b2" # Up-pointing triangle
U_UTRIS = "\u25b4" # Up-pointing triangle, small
U_RTRI = "\u25b6" # Right-pointing triangle
U_RTRIS = "\u25b8" # Right-pointing triangle, small
U_DTRI = "\u25bc" # Down-pointing triangle
U_DTRIS = "\u25be" # Down-pointing triangle, small
U_LTRI = "\u25c0" # Left-pointing triangle
U_LTRIS = "\u25c2" # Left-pointing triangle, small
# Special
U_UNKN = "\ufffd" # Unknown character
U_NAC1 = "\ufffe" # Not a character
U_NAC2 = "\uffff" # Not a character
# Placeholders
U_LBREAK = "\u21b2" # Downwards Arrow With Tip Leftwards
# HTML Equivalents
# ================
@@ -651,15 +648,15 @@ class nwUnicode:
H_TIMES = "&times;"
H_DIVIDE = "&divide;"
# Arrows
H_UTRI = "&#9650;"
H_UTRIS = "&#9652;"
H_RTRI = "&#9654;"
H_RTRIS = "&#9656;"
H_DTRI = "&#9660;"
H_DTRIS = "&#9662;"
H_LTRI = "&#9664;"
H_LTRIS = "&#9666;"
# Unicode symbols expected to be used on the UI
UI_SYMBOLS: Final[list[str]] = [
U_QUOT, U_APOS, U_LAQUO, U_RAQUO, U_LSQUO, U_RSQUO, U_SBQUO, U_SUQUO,
U_LDQUO, U_RDQUO, U_BDQUO, U_UDQUO, U_LSAQUO, U_RSAQUO, U_BDRQUO,
U_LCQUO, U_RCQUO, U_LWCQUO, U_RWCQUO, U_FGDASH, U_ENDASH, U_EMDASH,
U_HBAR, U_HELLIP, U_MAPOS, U_PRIME, U_DPRIME, U_NBSP, U_THSP, U_THNBSP,
U_ENSP, U_EMSP, U_MMSP, U_CHECK, U_CROSS, U_BULL, U_TRBULL, U_HYBULL,
U_FLOWER, U_PERMIL, U_DEGREE, U_MINUS, U_TIMES, U_DIVIDE, U_LBREAK,
]
class nwHtmlUnicode:

View File

@@ -131,12 +131,6 @@ class Index:
self._novelExtra = extra
return
def setItemClass(self, tHandle: str, itemClass: nwItemClass) -> None:
"""Update the class for all tags of a handle."""
logger.info("Updating class for '%s'", tHandle)
self._tagsIndex.updateClass(tHandle, itemClass.name)
return
##
# Public Methods
##
@@ -183,6 +177,16 @@ class Index:
self.scanText(tHandle, self._project.storage.getDocumentText(tHandle))
return
def refreshHandle(self, tHandle: str) -> None:
"""Update the class for all tags of a handle."""
if item := self._project.tree[tHandle]:
logger.info("Updating class for '%s'", tHandle)
if item.isInactiveClass():
self.deleteHandle(tHandle)
else:
self._tagsIndex.updateClass(tHandle, item.itemClass.name)
return
def indexChangedSince(self, checkTime: int | float) -> bool:
"""Check if the index has changed since a given time."""
return self._indexChange > float(checkTime)
@@ -704,17 +708,19 @@ class Index:
return 0, 0, 0
def getReferences(self, tHandle: str, sTitle: str | None = None) -> dict[str, list[str]]:
"""Extract all references made in a file, and optionally title
section.
"""Extract all tags and references made in a file, and
optionally title section.
"""
tRefs = {x: [] for x in nwKeyWords.VALID_KEYS}
refs = {x: [] for x in nwKeyWords.VALID_KEYS}
for rTitle, hItem in self._itemIndex.iterItemHeaders(tHandle):
if sTitle is None or sTitle == rTitle:
for aTag, refTypes in hItem.references.items():
for refType in refTypes:
if refType in tRefs:
tRefs[refType].append(self._tagsIndex.tagName(aTag))
return tRefs
if refType in refs:
refs[refType].append(self._tagsIndex.tagName(aTag))
if tag := hItem.tag:
refs[nwKeyWords.TAG_KEY] = [self._tagsIndex.tagName(tag)]
return refs
def getReferenceForHeader(self, tHandle: str, nHead: int, keyClass: str) -> list[str]:
"""Get the display names for a tags class for insertion into a
@@ -753,10 +759,12 @@ class Index:
"""Return all tags used by a specific document."""
return self._itemIndex.allItemTags(tHandle) if tHandle else []
def getClassTags(self, itemClass: nwItemClass | None) -> list[str]:
"""Return all tags based on itemClass."""
name = None if itemClass is None else itemClass.name
return self._tagsIndex.filterTagNames(name)
def getKeyWordTags(self, keyWord: str) -> list[str]:
"""Return all tags usable for a specific keyword."""
if keyWord in nwKeyWords.CAN_LOOKUP:
itemClass = nwKeyWords.KEY_CLASS.get(keyWord)
return self._tagsIndex.filterTagNames(itemClass.name if itemClass else None)
return []
def getTagsData(
self, activeOnly: bool = True

View File

@@ -342,20 +342,26 @@ class IndexHeading:
##
def getReferences(self) -> dict[str, list[str]]:
"""Extract all references for this heading."""
"""Extract all tags and references for this heading."""
refs = {x: [] for x in nwKeyWords.VALID_KEYS}
for tag, types in self._refs.items():
for keyword in types:
if keyword in refs and (name := self._cache.tags.tagName(tag)):
refs[keyword].append(name)
if name := self._cache.tags.tagName(self._tag):
refs[nwKeyWords.TAG_KEY] = [name]
return refs
def getReferencesByKeyword(self, keyword: str) -> list[str]:
"""Extract all references for this heading."""
refs = []
for tag, types in self._refs.items():
if keyword in types and (name := self._cache.tags.tagName(tag)):
if keyword == nwKeyWords.TAG_KEY:
if name := self._cache.tags.tagName(self._tag):
refs.append(name)
else:
for tag, types in self._refs.items():
if keyword in types and (name := self._cache.tags.tagName(tag)):
refs.append(name)
return refs
##

View File

@@ -439,7 +439,7 @@ class NWItem:
self.setClass(itemClass)
if self._type == nwItemType.FILE:
# Notify the index of the class change
self._project.index.setItemClass(self._handle, itemClass)
self._project.index.refreshHandle(self._handle)
if self._layout == nwItemLayout.NO_LAYOUT:
# If no layout is set, pick one

View File

@@ -29,7 +29,7 @@ import logging
from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot
from PyQt6.QtGui import QAction, QCloseEvent, QKeyEvent, QKeySequence
from PyQt6.QtWidgets import (
QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout, QLineEdit,
QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout, QLineEdit, QMenu,
QPushButton, QVBoxLayout, QWidget
)
@@ -600,6 +600,7 @@ class GuiPreferences(NDialog):
self.sidebar.addButton(title, section)
self.mainForm.addGroupLabel(title, section)
# Dialogue Quotes
self.dialogStyle = NComboBox(self)
self.dialogStyle.addItem(self.tr("None"), 0)
self.dialogStyle.addItem(self.tr("Single Quotes"), 1)
@@ -611,6 +612,15 @@ class GuiPreferences(NDialog):
self.tr("Applies to the selected quote styles.")
)
# Open-Ended Dialogue
self.allowOpenDial = NSwitch(self)
self.allowOpenDial.setChecked(CONFIG.allowOpenDial)
self.mainForm.addRow(
self.tr("Allow open-ended dialogue"), self.allowOpenDial,
self.tr("Highlight dialogue line with no closing quote.")
)
# Alternative Dialogue
self.altDialogOpen = QLineEdit(self)
self.altDialogOpen.setMaxLength(4)
self.altDialogOpen.setFixedWidth(boxFixed)
@@ -628,23 +638,30 @@ class GuiPreferences(NDialog):
self.tr("Custom highlighting of dialogue text.")
)
self.allowOpenDial = NSwitch(self)
self.allowOpenDial.setChecked(CONFIG.allowOpenDial)
self.mainForm.addRow(
self.tr("Allow open-ended dialogue"), self.allowOpenDial,
self.tr("Highlight dialogue line with no closing quote.")
)
# Dialogue Line
self.mnLineSymbols = QMenu(self)
for symbol in nwQuotes.ALLOWED:
label = trConst(nwQuotes.SYMBOLS.get(symbol, nwQuotes.DASHES.get(symbol, "None")))
self.mnLineSymbols.addAction(
f"[ {symbol } ] {label}",
lambda symbol=symbol: self._insertDialogLineSymbol(symbol)
)
self.dialogLine = QLineEdit(self)
self.dialogLine.setMaxLength(4)
self.dialogLine.setFixedWidth(boxFixed)
self.dialogLine.setMinimumWidth(100)
self.dialogLine.setAlignment(QtAlignCenter)
self.dialogLine.setText(CONFIG.dialogLine)
self.dialogLine.setText(" ".join(CONFIG.dialogLine))
self.dialogLineButton = NIconToolButton(self, iSz, "add", "green")
self.dialogLineButton.setMenu(self.mnLineSymbols)
self.mainForm.addRow(
self.tr("Dialogue line symbols"), self.dialogLine,
self.tr("Lines starting with any of these symbols are dialogue.")
self.tr("Lines starting with any of these symbols are dialogue."),
button=self.dialogLineButton
)
# Narrator Break
self.narratorBreak = NComboBox(self)
self.narratorDialog = NComboBox(self)
for key, value in nwQuotes.DASHES.items():
@@ -664,6 +681,7 @@ class GuiPreferences(NDialog):
self.tr("Alternates dialogue highlighting within any paragraph.")
)
# Emphasis
self.highlightEmph = NSwitch(self)
self.highlightEmph.setChecked(CONFIG.highlightEmph)
self.mainForm.addRow(
@@ -671,6 +689,7 @@ class GuiPreferences(NDialog):
self.tr("Applies to the document editor only.")
)
# Additional Spaces
self.showMultiSpaces = NSwitch(self)
self.showMultiSpaces.setChecked(CONFIG.showMultiSpaces)
self.mainForm.addRow(
@@ -906,6 +925,14 @@ class GuiPreferences(NDialog):
self.askBeforeBackup.setEnabled(state)
return
@pyqtSlot(str)
def _insertDialogLineSymbol(self, symbol: str) -> None:
"""Insert a symbol in the dialogue line box."""
current = self.dialogLine.text()
values = processDialogSymbols(f"{current} {symbol}")
self.dialogLine.setText(" ".join(values))
return
@pyqtSlot(bool)
def _toggleAutoReplaceMain(self, state: bool) -> None:
"""Toggle switches controlled by the auto replace switch."""

View File

@@ -37,7 +37,7 @@ from PyQt6.QtCore import QMargins, QSize
from novelwriter import __version__
from novelwriter.common import firstFloat, xmlElement, xmlSubElem
from novelwriter.constants import nwHeadFmt, nwStyles
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
from novelwriter.formats.tokenizer import Tokenizer
from novelwriter.types import QtHexRgb
@@ -480,7 +480,7 @@ class ToDocX(Tokenizer):
xmlSubElem(rPr, _wTag("color"), attrib={W_VAL: _docXCol(color)})
if isinstance(text, str):
for segment in RX_TEXT.split(text):
for segment in RX_TEXT.split(stripEscape(text)):
if segment == "\n":
xmlSubElem(xR, _wTag("br"))
elif segment == "\t":

View File

@@ -495,12 +495,10 @@ class Tokenizer(ABC):
def doPreProcessing(self) -> None:
"""Run pre-processing jobs before the text is tokenized."""
# Process the user's auto-replace dictionary
if autoReplace := self._project.data.autoReplace:
repDict = {}
for aKey, aVal in autoReplace.items():
repDict[f"<{aKey}>"] = aVal
xRep = re.compile("|".join([re.escape(k) for k in repDict.keys()]), flags=re.DOTALL)
self._text = xRep.sub(lambda x: repDict[x.group(0)], self._text)
if entry := self._project.data.autoReplace:
replace = {f"<{k}>": v for k, v in entry.items()}
rxRep = re.compile("|".join([re.escape(k) for k in replace]), flags=re.DOTALL)
self._text = rxRep.sub(lambda x: replace[x.group(0)], self._text)
return
def tokenizeText(self) -> None:
@@ -882,31 +880,21 @@ class Tokenizer(ABC):
if nBlock[0] != BlockTyp.TEXT:
# Next block is not text, so we add the buffer to blocks
nLines = len(pLines)
cStyle = pLines[0][4]
if firstIndent and not (self._noIndent or cStyle & BlockFmt.ALIGNED):
# If paragraph indentation is enabled, not temporarily
# turned off, and the block is not aligned, we add the
# text indentation flag
cStyle |= BlockFmt.IND_T
tFmt: T_Formats = []
pTxt = ""
cStyle = BlockFmt.NONE
if nLines == 1:
# The paragraph contains a single line, so we just save
# that directly to the blocks list. If justify is
# enabled, and there is no alignment, we apply it.
if doJustify and not cStyle & BlockFmt.ALIGNED:
cStyle |= BlockFmt.JUSTIFY
# The paragraph contains a single line
tFmt = pLines[0][3]
pTxt = pLines[0][2].translate(transMapB)
sBlocks.append((
BlockTyp.TEXT, pLines[0][1], pTxt, pLines[0][3], cStyle
))
cStyle = pLines[0][4]
elif nLines > 1:
# The paragraph contains multiple lines, so we need to
# join them according to the line break policy, and
# recompute all the formatting markers
tTxt = ""
tFmt: T_Formats = []
for aBlock in pLines:
tLen = len(tTxt)
tTxt += f"{aBlock[2]}{lineSep}"
@@ -914,6 +902,18 @@ class Tokenizer(ABC):
cStyle |= aBlock[4]
pTxt = tTxt[:-1].translate(transMapB)
if nLines:
isAligned = cStyle & BlockFmt.ALIGNED
if firstIndent and not (self._noIndent or isAligned):
# If paragraph indentation is enabled, not temporarily
# turned off, and the block is not aligned, we add the
# text indentation flag
cStyle |= BlockFmt.IND_T
if doJustify and not isAligned:
cStyle |= BlockFmt.JUSTIFY
sBlocks.append((
BlockTyp.TEXT, pLines[0][1], pTxt, tFmt, cStyle
))
@@ -1170,12 +1170,18 @@ class Tokenizer(ABC):
class HeadingFormatter:
def __init__(self, project: NWProject) -> None:
def __init__(
self,
project: NWProject,
chapter: int = 0,
scene: int = 0,
absolute: int = 0,
) -> None:
self._project = project
self._handle = None
self._chCount = 0
self._scChCount = 0
self._scAbsCount = 0
self._chapter = chapter
self._scene = scene
self._absolute = absolute
return
def setHandle(self, tHandle: str | None) -> None:
@@ -1185,42 +1191,42 @@ class HeadingFormatter:
def incChapter(self) -> None:
"""Increment the chapter counter."""
self._chCount += 1
self._chapter += 1
return
def incScene(self) -> None:
"""Increment the scene counters."""
self._scChCount += 1
self._scAbsCount += 1
self._scene += 1
self._absolute += 1
return
def resetAll(self) -> None:
"""Reset all counters."""
self._chCount = 0
self._scChCount = 0
self._scAbsCount = 0
self._chapter = 0
self._scene = 0
self._absolute = 0
return
def resetScene(self) -> None:
"""Reset the chapter scene counter."""
self._scChCount = 0
self._scene = 0
return
def apply(self, hFormat: str, text: str, nHead: int) -> str:
"""Apply formatting to a specific heading."""
hFormat = hFormat.replace(nwHeadFmt.TITLE, text)
hFormat = hFormat.replace(nwHeadFmt.BR, "\n")
hFormat = hFormat.replace(nwHeadFmt.CH_NUM, str(self._chCount))
hFormat = hFormat.replace(nwHeadFmt.SC_NUM, str(self._scChCount))
hFormat = hFormat.replace(nwHeadFmt.SC_ABS, str(self._scAbsCount))
hFormat = hFormat.replace(nwHeadFmt.CH_NUM, str(self._chapter))
hFormat = hFormat.replace(nwHeadFmt.SC_NUM, str(self._scene))
hFormat = hFormat.replace(nwHeadFmt.SC_ABS, str(self._absolute))
if nwHeadFmt.CH_WORD in hFormat:
chWord = self._project.localLookup(self._chCount)
chWord = self._project.localLookup(self._chapter)
hFormat = hFormat.replace(nwHeadFmt.CH_WORD, chWord)
if nwHeadFmt.CH_ROML in hFormat:
chRom = numberToRoman(self._chCount, toLower=True)
chRom = numberToRoman(self._chapter, toLower=True)
hFormat = hFormat.replace(nwHeadFmt.CH_ROML, chRom)
if nwHeadFmt.CH_ROMU in hFormat:
chRom = numberToRoman(self._chCount, toLower=False)
chRom = numberToRoman(self._chapter, toLower=False)
hFormat = hFormat.replace(nwHeadFmt.CH_ROMU, chRom)
if nwHeadFmt.CHAR_POV in hFormat or nwHeadFmt.CHAR_FOCUS in hFormat:

View File

@@ -36,12 +36,13 @@ from PyQt6.QtPrintSupport import QPrinter
from novelwriter import __version__
from novelwriter.constants import nwStyles, nwUnicode
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
from novelwriter.formats.tokenizer import HEADINGS, Tokenizer
from novelwriter.types import (
QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignLeft, QtAlignRight,
QtKeepAnchor, QtMoveAnchor, QtPageBreakAfter, QtPageBreakBefore,
QtPropLineHeight, QtTransparent, QtVAlignNormal, QtVAlignSub, QtVAlignSuper
QtKeepAnchor, QtMoveAnchor, QtPageBreakAfter, QtPageBreakAuto,
QtPageBreakBefore, QtPropLineHeight, QtTransparent, QtVAlignNormal,
QtVAlignSub, QtVAlignSuper
)
if TYPE_CHECKING:
@@ -253,8 +254,10 @@ class ToQTextDocument(Tokenizer):
elif tType in HEADINGS:
bFmt, cFmt = self._genHeadStyle(tType, tMeta, bFmt)
newBlock(cursor, bFmt)
cursor.insertText(tText, cFmt)
for tPart in tText.split("\n"):
newBlock(cursor, bFmt)
cursor.insertText(tPart, cFmt)
bFmt.setPageBreakPolicy(QtPageBreakAuto)
elif tType == BlockTyp.SEP:
newBlock(cursor, bFmt)
@@ -343,7 +346,7 @@ class ToQTextDocument(Tokenizer):
for pos, fmt, data in tFmt:
# Insert buffer with previous format
cursor.insertText(temp[start:pos], cFmt)
cursor.insertText(stripEscape(temp[start:pos]), cFmt)
# Construct next format
if fmt == TextFmt.B_B:
@@ -425,13 +428,12 @@ class ToQTextDocument(Tokenizer):
if field := data.partition(":")[2]:
self._usedFields.append((cursor.position(), field))
cursor.insertText("0", cFmt)
pass
# Move pos for next pass
start = pos
# Insert whatever is left in the buffer
cursor.insertText(temp[start:], cFmt)
cursor.insertText(stripEscape(temp[start:]), cFmt)
return

View File

@@ -1090,11 +1090,14 @@ class GuiDocEditor(QPlainTextEdit):
show = self._completer.updateMetaText(text, bPos)
else:
show = self._completer.updateCommentText(text, bPos)
point = self.cursorRect().bottomRight()
self._completer.move(viewport.mapToGlobal(point))
self._completer.setVisible(show)
if show:
point = self.cursorRect().bottomRight()
self._completer.move(viewport.mapToGlobal(point))
self._completer.show()
else:
self._completer.close()
else:
self._completer.setVisible(False)
self._completer.close()
if self._doReplace and added == 1:
cursor = self.textCursor()
@@ -2113,9 +2116,7 @@ class CommandCompleter(QMenu):
length = len(lookup)
suffix = ""
options = sorted(filter(
lambda x: lookup in x.lower(), SHARED.project.index.getClassTags(
nwKeyWords.KEY_CLASS.get(kw.strip())
)
lambda x: lookup in x.lower(), SHARED.project.index.getKeyWordTags(kw.strip())
))[:15]
if not options:

View File

@@ -228,6 +228,8 @@ class GuiDocViewer(QTextBrowser):
qDoc.setTheme(self._docTheme)
qDoc.initDocument()
qDoc.setKeywords(True)
qDoc.setCommentType(nwComment.NOTE, CONFIG.viewComments)
qDoc.setCommentType(nwComment.STORY, CONFIG.viewComments)
qDoc.setCommentType(nwComment.PLAIN, CONFIG.viewComments)
qDoc.setCommentType(nwComment.SYNOPSIS, CONFIG.viewSynopsis)
qDoc.setCommentType(nwComment.SHORT, CONFIG.viewSynopsis)

View File

@@ -593,6 +593,7 @@ class GuiNovelTree(NTreeView):
lines = []
if head := SHARED.project.index.getItemHeading(tHandle, sTitle):
tags = head.getReferences()
appendTags(tags, nwKeyWords.TAG_KEY, lines)
appendTags(tags, nwKeyWords.POV_KEY, lines)
appendTags(tags, nwKeyWords.FOCUS_KEY, lines)
appendTags(tags, nwKeyWords.CHAR_KEY, lines)

View File

@@ -43,7 +43,7 @@ from PyQt6.QtWidgets import (
from novelwriter import CONFIG, SHARED
from novelwriter.common import fuzzyTime, qtLambda
from novelwriter.constants import nwLabels, nwStats, trStats
from novelwriter.constants import nwHeadFmt, nwLabels, nwStats, nwUnicode, trStats
from novelwriter.core.buildsettings import BuildCollection, BuildSettings
from novelwriter.core.docbuild import NWBuildDocument
from novelwriter.extensions.modified import NIconToggleButton, NIconToolButton, NToolDialog
@@ -595,11 +595,7 @@ class _DetailsWidget(QWidget):
item.addChild(sub)
# Headings
hFmt = HeadingFormatter(SHARED.project)
hFmt.incChapter()
hFmt.incScene()
hFmt.resetScene()
hFmt.incScene()
hFmt = HeadingFormatter(SHARED.project, 7, 5, 23)
title = self.tr("Title")
hidden = self.tr("Hidden")
@@ -620,7 +616,8 @@ class _DetailsWidget(QWidget):
if build.getBool(hHide):
sub.setText(1, f"[{hidden}]")
else:
sub.setText(1, hFmt.apply(build.getStr(hFormat), title, 0))
preview = build.getStr(hFormat).replace(nwHeadFmt.BR, nwUnicode.U_LBREAK)
sub.setText(1, hFmt.apply(preview, title, 0))
item.addChild(sub)
# Text Content

View File

@@ -38,7 +38,7 @@ from PyQt6.QtWidgets import (
from novelwriter import CONFIG, SHARED
from novelwriter.common import describeFont, fontMatcher, qtAddAction, qtLambda
from novelwriter.constants import nwHeadFmt, nwKeyWords, nwLabels, trConst
from novelwriter.constants import nwHeadFmt, nwKeyWords, nwLabels, nwUnicode, trConst
from novelwriter.core.buildsettings import BuildSettings, FilterMode
from novelwriter.extensions.configlayout import (
NColorLabel, NFixedPage, NScrollableForm, NScrollablePage
@@ -795,12 +795,15 @@ class _HeadingsTab(NScrollablePage):
def loadContent(self) -> None:
"""Populate the widgets."""
self.fmtPart.setText(self._build.getStr("headings.fmtPart"))
self.fmtChapter.setText(self._build.getStr("headings.fmtChapter"))
self.fmtUnnumbered.setText(self._build.getStr("headings.fmtUnnumbered"))
self.fmtScene.setText(self._build.getStr("headings.fmtScene"))
self.fmtAScene.setText(self._build.getStr("headings.fmtAltScene"))
self.fmtSection.setText(self._build.getStr("headings.fmtSection"))
def fmtBreak(text: str) -> str:
return text.replace(nwHeadFmt.BR, nwUnicode.U_LBREAK)
self.fmtPart.setText(fmtBreak(self._build.getStr("headings.fmtPart")))
self.fmtChapter.setText(fmtBreak(self._build.getStr("headings.fmtChapter")))
self.fmtUnnumbered.setText(fmtBreak(self._build.getStr("headings.fmtUnnumbered")))
self.fmtScene.setText(fmtBreak(self._build.getStr("headings.fmtScene")))
self.fmtAScene.setText(fmtBreak(self._build.getStr("headings.fmtAltScene")))
self.fmtSection.setText(fmtBreak(self._build.getStr("headings.fmtSection")))
self.swtPart.setChecked(self._build.getBool("headings.hidePart"))
self.swtChapter.setChecked(self._build.getBool("headings.hideChapter"))
@@ -880,7 +883,7 @@ class _HeadingsTab(NScrollablePage):
text = ""
label = self.tr("None")
self.editTextBox.setPlainText(text.replace(nwHeadFmt.BR, "\n"))
self.editTextBox.setPlainText(text.replace(nwUnicode.U_LBREAK, "\n"))
self.lblEditForm.setText(self.tr("Editing: {0}").format(label))
return
@@ -893,25 +896,26 @@ class _HeadingsTab(NScrollablePage):
def _saveFormat(self) -> None:
"""Save the format from the edit text box."""
heading = self._editing
text = self.editTextBox.toPlainText().strip().replace("\n", nwHeadFmt.BR)
text = self.editTextBox.toPlainText().strip().replace("\n", nwUnicode.U_LBREAK)
value = text.replace(nwUnicode.U_LBREAK, nwHeadFmt.BR)
if heading == self.EDIT_TITLE:
self.fmtPart.setText(text)
self._build.setValue("headings.fmtPart", text)
self._build.setValue("headings.fmtPart", value)
elif heading == self.EDIT_CHAPTER:
self.fmtChapter.setText(text)
self._build.setValue("headings.fmtChapter", text)
self._build.setValue("headings.fmtChapter", value)
elif heading == self.EDIT_UNNUM:
self.fmtUnnumbered.setText(text)
self._build.setValue("headings.fmtUnnumbered", text)
self._build.setValue("headings.fmtUnnumbered", value)
elif heading == self.EDIT_SCENE:
self.fmtScene.setText(text)
self._build.setValue("headings.fmtScene", text)
self._build.setValue("headings.fmtScene", value)
elif heading == self.EDIT_HSCENE:
self.fmtAScene.setText(text)
self._build.setValue("headings.fmtAltScene", text)
self._build.setValue("headings.fmtAltScene", value)
elif heading == self.EDIT_SECTION:
self.fmtSection.setText(text)
self._build.setValue("headings.fmtSection", text)
self._build.setValue("headings.fmtSection", value)
else:
return

View File

@@ -52,6 +52,7 @@ QtVAlignSuper = QTextCharFormat.VerticalAlignment.AlignSuperScript
QtPageBreakBefore = QTextFormat.PageBreakFlag.PageBreak_AlwaysBefore
QtPageBreakAfter = QTextFormat.PageBreakFlag.PageBreak_AlwaysAfter
QtPageBreakAuto = QTextFormat.PageBreakFlag.PageBreak_Auto
QtPropLineHeight = 1 # QTextBlockFormat.LineHeightTypes.ProportionalHeight

View File

@@ -272,24 +272,12 @@ if __name__ == "__main__":
cmdBuildUbuntu.set_defaults(func=utils.build_debian.launchpad)
# Build AppImage
cmdBuildAppImage = parsers.add_parser(
"build-appimage", help=(
"Build an AppImage. "
"Argument --linux-tag defaults manylinux_2_28_x86_64, and --python-version to 3.13."
)
)
cmdBuildAppImage.add_argument(
"--linux-tag",
default="manylinux_2_28_x86_64",
help=(
"Linux compatibility tag (e.g. manylinux_2_28_x86_64) "
"see https://python-appimage.readthedocs.io/en/latest/#available-python-appimages "
"and https://github.com/pypa/manylinux for a list of valid tags."
),
)
cmdBuildAppImage.add_argument(
"--python-version", default="3.13", help="Python version (e.g. 3.13)"
)
# See https://github.com/pypa/manylinux
# See https://python-appimage.readthedocs.io/en/latest/#available-python-appimages
cmdBuildAppImage = parsers.add_parser("build-appimage", help="Build an AppImage.")
cmdBuildAppImage.add_argument("linux", help="Manylinux version, e.g. manylinux_2_28.")
cmdBuildAppImage.add_argument("arch", help="Architecture, e.g. x86_64.")
cmdBuildAppImage.add_argument("python", help="Python version, e.g. 3.13.")
cmdBuildAppImage.set_defaults(func=utils.build_appimage.appImage)
# Build Windows Inno Setup Installer

View File

@@ -7,9 +7,13 @@ name = "novelWriter"
authors = [
{name = "Veronica Berglyd Olsen", email = "code@vkbo.net"},
]
description = "A markdown-like text editor for planning and writing novels"
description = "A plain text editor for planning and writing novels"
readme = {file = "setup/description_pypi.md", content-type = "text/markdown"}
license = {text = "GNU General Public License v3"}
license = "GPL-3.0-or-later AND Apache-2.0 AND CC-BY-4.0"
license-files = [
"LICENSE.md",
"setup/LICENSE-Apache-2.0.txt",
]
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
@@ -17,7 +21,6 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Development Status :: 5 - Production/Stable",
"Operating System :: OS Independent",
"Intended Audience :: End Users/Desktop",

View File

@@ -1,10 +1,11 @@
%%~name: Making a Scene
%%~path: 6a2d6d5f4f401/636b6aa9b697b
%%~kind: NOVEL/DOCUMENT
%%~hash: 1f3d98a6a27b4f9a7f2239fcd78f9e2263cd3b97
%%~date: Unknown/2025-05-18 22:36:59
%%~hash: b39201b02e3db63493d61d09e5fec5765a937255
%%~date: Unknown/2025-06-24 09:09:56
### Making a Scene
@tag: Scene
@pov: Jane
@char: John, Jane
@location: Earth

View File

@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.7" hexVersion="0x020700f0" fileVersion="1.5" fileRevision="5" timeStamp="2025-05-31 23:25:11">
<project id="e2be99af-f9bf-4403-857a-c3d1ac25abea" saveCount="2193" autoCount="286" editTime="96887">
<novelWriterXML appVersion="2.7.3" hexVersion="0x020703f0" fileVersion="1.5" fileRevision="5" timeStamp="2025-07-07 17:06:54">
<project id="e2be99af-f9bf-4403-857a-c3d1ac25abea" saveCount="2210" autoCount="287" editTime="97156">
<name>Sample Project</name>
<author>Jane Smith</author>
</project>
@@ -58,7 +58,7 @@
<name status="sf24ce6" import="ia857f0" active="yes">Chapter One</name>
</item>
<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="718" />
<meta expanded="no" heading="H3" charCount="2999" wordCount="530" paraCount="16" cursorPos="93" />
<name status="s90e6c9" import="ia857f0" active="yes">Making a Scene</name>
</item>
<item handle="bc0cbd2a407f3" parent="6a2d6d5f4f401" root="7031beac91f75" order="1" type="FILE" class="NOVEL" layout="DOCUMENT">

View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -24,7 +24,7 @@ cat > $HOME/.local/share/applications/novelWriter.desktop <<EOF
[Desktop Entry]
Type=Application
Name=novelWriter
Comment=A markdown-like text editor for planning and writing novels
Comment=A plain text editor for planning and writing novels
Exec=${IMGPATH} %f
Icon=${ICONPATH}
Categories=Qt;Office;WordProcessor;

View File

@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
Name=novelWriter
Comment=A markdown-like text editor for planning and writing novels
Comment=A plain text editor for planning and writing novels
Exec=novelwriter %f
Icon=novelwriter
Categories=Qt;Office;WordProcessor;

View File

@@ -10,10 +10,4 @@ X-Python3-Version: >= 3.10
Package: novelwriter
Architecture: all
Depends: ${misc:Depends}, ${python3:Depends}, python3 (>=3.10), python3-pyqt6 (>= 6.4), python3-pyqt6.qtsvg (>= 6.4), python3-enchant (>= 2.0)
Description: A markdown-like text editor for planning and writing novels
novelWriter is a plain text editor designed for writing novels assembled from
many smaller text documents. It uses a minimal formatting syntax inspired by
Markdown, and adds a meta data syntax for comments, synopsis, and
cross-referencing. It's designed to be a simple text editor that allows for
easy organisation of text and notes, using human readable text files as
storage for robustness.
Description: A plain text editor for planning and writing novels

BIN
setup/icons/novelwriter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@@ -11,7 +11,7 @@
<key>CFBundleExecutable</key>
<string>novelWriter</string>
<key>CFBundleGetInfoString</key>
<string>novelWriter: A markdown-like text editor for planning and writing novels.</string>
<string>novelWriter: A plain text editor for planning and writing novels.</string>
<key>CFBundleIconFile</key>
<string>novelwriter.icns</string>
<key>CFBundleIdentifier</key>

View File

@@ -174,7 +174,7 @@ rm lib/python3.*/site-packages/PyQt6/QtWebEngine* || true
rm -r lib/python3.*/site-packages/PyQt6/Qt6/translations/qtwebengine* || true
rm -r lib/python3.*/site-packages/PyQt6/Qt6/plugins/webview/libqtwebview* || true
# Remove unneeded QtQuick/Decaritive components
# Remove unneeded QtQuick/Declarative components
rm lib/python3.*/site-packages/PyQt6/QtQml* || true
rm lib/python3.*/site-packages/PyQt6/QtQuick* || true
rm lib/python3.*/site-packages/PyQt6/WebChannel* || true
@@ -200,16 +200,16 @@ mkdir -p $RLS_DIR
# --- Create DMG -------------------------------------------------------------------------------- #
# Generate .dmg
echo "Packageing DMG ..."
echo "Packaging DMG ..."
brew install create-dmg
create-dmg --volname "novelWriter $VERSION" --volicon $SRC_DIR/setup/macos/novelwriter.icns \
--window-pos 200 120 --window-size 800 400 --icon-size 100 \
--icon novelWriter.app 200 190 --hide-extension novelWriter.app \
--app-drop-link 600 185 $RLS_DIR/novelWriter-"${VERSION}"-$ARCH.dmg "$BUILD_DIR"/
--app-drop-link 600 185 $RLS_DIR/novelwriter-"${VERSION}"-$ARCH.dmg "$BUILD_DIR"/
pushd $RLS_DIR || exit 1
shasum -a 256 novelWriter-"${VERSION}"-$ARCH.dmg | tee novelWriter-"${VERSION}"-$ARCH.dmg.sha256
shasum -a 256 novelwriter-"${VERSION}"-$ARCH.dmg | tee novelwriter-"${VERSION}"-$ARCH.dmg.sha256
popd || exit 1
rm -r $CONDA_PATH

View File

@@ -95,12 +95,35 @@ def testCoreIndex_LoadSave(qtbot, monkeypatch, prjLipsum, nwGUI, tstPaths):
tagIndex = str(index._tagsIndex.packData())
itemsIndex = str(index._itemIndex.packData())
# Update item class
bHandle = "4c4f28287af27"
bItem = project.tree[bHandle]
assert bItem is not None
tagsBod = index._tagsIndex["Bod"]
assert tagsBod is not None
assert tagsBod["handle"] == bHandle
assert tagsBod["class"] == "CHARACTER"
bItem.setClass(nwItemClass.CUSTOM)
index.refreshHandle(bHandle)
assert tagsBod is not None
assert tagsBod["handle"] == bHandle
assert tagsBod["class"] == "CUSTOM"
# Update item class to inactive
bItem.setClass(nwItemClass.TRASH)
index.refreshHandle(bHandle)
assert "Bod" not in index._tagsIndex
bItem.setClass(nwItemClass.CHARACTER)
index.reIndexHandle(bHandle)
# Delete a handle
assert index._tagsIndex["Bod"] is not None
assert index._itemIndex["4c4f28287af27"] is not None
index.deleteHandle("4c4f28287af27")
assert index._itemIndex[bHandle] is not None
index.deleteHandle(bHandle)
assert index._tagsIndex["Bod"] is None
assert index._itemIndex["4c4f28287af27"] is None
assert index._itemIndex[bHandle] is None
# Clear the index
index.clear()
@@ -672,6 +695,7 @@ def testCoreIndex_ExtractData(nwGUI, fncPath, mockRnd):
))
assert index.scanText(nHandle, (
"# Hello World!\n"
"@tag: Scene\n"
"@pov: Jane\n"
"@char: Jane, John\n\n"
"% this is a comment\n\n"
@@ -726,11 +750,13 @@ def testCoreIndex_ExtractData(nwGUI, fncPath, mockRnd):
# Look up an invalid handle
refs = index.getReferences("Not a handle")
assert refs["@tag"] == []
assert refs["@pov"] == []
assert refs["@char"] == []
# The novel file should now refer to Jane as @pov and @char
refs = index.getReferences(nHandle)
assert refs["@tag"] == ["Scene"]
assert refs["@pov"] == ["Jane"]
assert refs["@char"] == ["Jane", "John"]
@@ -766,11 +792,12 @@ def testCoreIndex_ExtractData(nwGUI, fncPath, mockRnd):
assert index.getDocumentTags(cHandle) == ["jane"]
assert index.getDocumentTags(None) == []
# getClassTags
# ============
assert index.getClassTags(None) == ["Jane", "John"]
assert index.getClassTags(nwItemClass.CHARACTER) == ["Jane", "John"]
assert index.getClassTags(nwItemClass.PLOT) == []
# getKeyWordTags
# ==============
assert index.getKeyWordTags("@mention") == ["Jane", "John", "Scene"]
assert index.getKeyWordTags("@char") == ["Jane", "John"]
assert index.getKeyWordTags("@plot") == []
assert index.getKeyWordTags("@tag") == []
# getTagsData
# ===========

View File

@@ -267,6 +267,7 @@ def testCoreIndexData_IndexHeadingReferences():
head = IndexHeading(cache, "T0001")
# Add some references
head.setTag("Scene")
head.addReference("Jane", "@pov")
head.addReference("Jane", "@char")
head.addReference("John", "@char")
@@ -290,6 +291,7 @@ def testCoreIndexData_IndexHeadingReferences():
}
# Set names
cache.tags.add("Scene", "Scene", "0000000000000", "T00001", "NOVEL")
cache.tags.add("Jane", "Jane", "0000000000000", "T00001", "CHARACTER")
cache.tags.add("John", "John", "0000000000000", "T00001", "CHARACTER")
cache.tags.add("Main", "Main", "0000000000000", "T00001", "PLOT")
@@ -301,7 +303,7 @@ def testCoreIndexData_IndexHeadingReferences():
"@plot": ["Main"],
"@object": ["Gun"],
"@story": [],
"@tag": [],
"@tag": ["Scene"],
"@focus": [],
"@custom": [],
"@time": [],
@@ -316,7 +318,7 @@ def testCoreIndexData_IndexHeadingReferences():
assert head.getReferencesByKeyword("@plot") == ["Main"]
assert head.getReferencesByKeyword("@object") == ["Gun"]
assert head.getReferencesByKeyword("@story") == []
assert head.getReferencesByKeyword("@tag") == []
assert head.getReferencesByKeyword("@tag") == ["Scene"]
assert head.getReferencesByKeyword("@focus") == []
assert head.getReferencesByKeyword("@custom") == []
assert head.getReferencesByKeyword("@time") == []

View File

@@ -268,14 +268,17 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
# Text Highlighting
prefs.dialogStyle.setCurrentData(3, 0)
prefs.allowOpenDial.setChecked(False)
prefs.dialogLine.setText("–")
prefs.narratorBreak.setCurrentData("–", "")
prefs.narratorDialog.setCurrentData("–", "")
prefs.altDialogOpen.setText("<")
prefs.altDialogClose.setText(">")
prefs.dialogLine.setText(nwUnicode.U_EMDASH)
prefs.narratorBreak.setCurrentData(nwUnicode.U_EMDASH, "")
prefs.narratorDialog.setCurrentData(nwUnicode.U_EMDASH, "")
prefs.altDialogOpen.setText("%") # Symbol also tests for #2455
prefs.altDialogClose.setText("%") # Symbol also tests for #2455
prefs.highlightEmph.setChecked(False)
prefs.showMultiSpaces.setChecked(False)
prefs._insertDialogLineSymbol(nwUnicode.U_ENDASH)
assert prefs.dialogLine.text() == f"{nwUnicode.U_ENDASH} {nwUnicode.U_EMDASH}"
assert CONFIG.dialogStyle == 2
assert CONFIG.allowOpenDial is True
assert CONFIG.dialogLine == ""
@@ -398,11 +401,11 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
# Text Highlighting
assert CONFIG.dialogStyle == 3
assert CONFIG.allowOpenDial is False
assert CONFIG.dialogLine == "–"
assert CONFIG.narratorBreak == "–"
assert CONFIG.narratorDialog == "–"
assert CONFIG.altDialogOpen == "<"
assert CONFIG.altDialogClose == ">"
assert CONFIG.dialogLine == f"{nwUnicode.U_ENDASH}{nwUnicode.U_EMDASH}"
assert CONFIG.narratorBreak == nwUnicode.U_EMDASH
assert CONFIG.narratorDialog == nwUnicode.U_EMDASH
assert CONFIG.altDialogOpen == "%"
assert CONFIG.altDialogClose == "%"
assert CONFIG.highlightEmph is False
assert CONFIG.showMultiSpaces is False

View File

@@ -147,9 +147,6 @@ def testFmtToHtml_ConvertParagraphs(mockGUI):
html._isNovel = True
html._isFirst = True
# Paragraphs
# ==========
# Text
html._text = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
html.tokenizeText()
@@ -280,6 +277,54 @@ def testFmtToHtml_ConvertParagraphs(mockGUI):
)
@pytest.mark.core
def testFmtToHtml_Alignment(mockGUI):
"""Test paragraph alignment in the ToHtml class."""
project = NWProject()
html = ToHtml(project)
html.initDocument()
# Left
html._text = "This is text <<\nspanning multiple\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: left;'>This is text<br>spanning multiple<br>lines</p>\n"
)
# Right
html._text = ">> This is text\nspanning multiple\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: right;'>This is text<br>spanning multiple<br>lines</p>\n"
)
# Centre
html._text = ">> This is text <<\nspanning multiple\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: center;'>This is text<br>spanning multiple<br>lines</p>\n"
)
# Left before Right
html._text = ">> This is text\nspanning multiple <<\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: left;'>This is text<br>spanning multiple<br>lines</p>\n"
)
# Right before Centre
html._text = ">> This is text <<\n>> spanning multiple\nlines"
html.tokenizeText()
html.doConvert()
assert html._pages[-1] == (
"<p style='text-align: right;'>This is text<br>spanning multiple<br>lines</p>\n"
)
@pytest.mark.core
def testFmtToHtml_Dialog(mockGUI):
"""Test paragraph formats in the ToHtml class."""

View File

@@ -1074,6 +1074,80 @@ def testFmtToken_Paragraphs(mockGUI):
]
@pytest.mark.core
def testFmtToken_BreakAlignIndent(mockGUI):
"""Test the splitting of paragraphs with alignment."""
project = NWProject()
tokens = BareTokenizer(project)
tokens._handle = TMH
for text in [
"This is text <<\nspanning multiple\nlines",
"This is text\nspanning multiple <<\nlines",
"This is text\nspanning multiple\nlines <<",
]:
# Preserve Breaks
tokens.setKeepLineBreaks(True)
tokens._text = text
tokens.tokenizeText()
assert tokens._blocks == [
(BlockTyp.TEXT, "", "This is text\nspanning multiple\nlines", [], BlockFmt.LEFT),
]
# Don't Preserve Breaks
tokens.setKeepLineBreaks(False)
tokens._text = text
tokens.tokenizeText()
assert tokens._blocks == [
(BlockTyp.TEXT, "", "This is text spanning multiple lines", [], BlockFmt.LEFT),
]
# With Justify
# This should disable justify
tokens.setKeepLineBreaks(True)
tokens.setJustify(True)
tokens._text = text
tokens.tokenizeText()
assert tokens._blocks == [
(BlockTyp.TEXT, "", "This is text\nspanning multiple\nlines", [], BlockFmt.LEFT),
]
# With Indent
# This should disable indent
tokens.setKeepLineBreaks(True)
tokens.setFirstLineIndent(True, 1.0, False)
tokens._text = text
tokens.tokenizeText()
assert tokens._blocks == [
(BlockTyp.TEXT, "", "This is text\nspanning multiple\nlines", [], BlockFmt.LEFT),
]
@pytest.mark.core
def testFmtToken_BreakJustify(mockGUI):
"""Test the of processing of justify with breaks."""
project = NWProject()
tokens = BareTokenizer(project)
tokens._handle = TMH
tokens.setJustify(True)
# Applied to all lines when breaks are preserved
tokens._text = "This is text\nspanning multiple\nlines"
tokens.setKeepLineBreaks(True)
tokens.tokenizeText()
assert tokens._blocks == [
(BlockTyp.TEXT, "", "This is text\nspanning multiple\nlines", [], BlockFmt.JUSTIFY),
]
# Turning off breaks should make no difference (see issue #2426)
tokens._text = "This is text\nspanning multiple\nlines"
tokens.setKeepLineBreaks(False)
tokens.tokenizeText()
assert tokens._blocks == [
(BlockTyp.TEXT, "", "This is text spanning multiple lines", [], BlockFmt.JUSTIFY),
]
@pytest.mark.core
def testFmtToken_TextFormat(mockGUI):
"""Test the tokenization of text formats in the Tokenizer class."""
@@ -1654,7 +1728,7 @@ def testFmtToken_ProcessHeaders(mockGUI):
# H2: Chapter Word Number
tokens._text = "## Chapter\n"
tokens.setChapterFormat(f"Chapter {nwHeadFmt.CH_WORD}")
tokens._hFormatter._chCount = 0
tokens._hFormatter._chapter = 0
tokens.tokenizeText()
assert tokens._blocks == [
(BlockTyp.HEAD1, TM1, "Chapter One", [], BlockFmt.PBB),
@@ -1728,8 +1802,8 @@ def testFmtToken_ProcessHeaders(mockGUI):
# H3: Scene w/Absolute Number
tokens._text = "### A Scene\n"
tokens.setSceneFormat(f"Scene {nwHeadFmt.SC_ABS}", False)
tokens._hFormatter._scAbsCount = 0
tokens._hFormatter._scChCount = 0
tokens._hFormatter._scene = 0
tokens._hFormatter._absolute = 0
tokens.tokenizeText()
assert tokens._blocks == [
(BlockTyp.HEAD2, TM1, "Scene 1", [], BlockFmt.NONE),
@@ -1738,8 +1812,8 @@ def testFmtToken_ProcessHeaders(mockGUI):
# H3: Scene w/Chapter Number
tokens._text = "### A Scene\n"
tokens.setSceneFormat(f"Scene {nwHeadFmt.CH_NUM}.{nwHeadFmt.SC_NUM}", False)
tokens._hFormatter._scAbsCount = 0
tokens._hFormatter._scChCount = 1
tokens._hFormatter._scene = 1
tokens._hFormatter._absolute = 0
tokens.tokenizeText()
assert tokens._blocks == [
(BlockTyp.HEAD2, TM1, "Scene 3.2", [], BlockFmt.NONE),
@@ -2544,9 +2618,9 @@ def testFmtToken_HeadingFormatter(fncPath, mockGUI, mockRnd):
# Special Formats
# ===============
formatter._chCount = 2
formatter._scChCount = 3
formatter._scAbsCount = 8
formatter._chapter = 2
formatter._scene = 3
formatter._absolute = 8
# Chapter Number Word
cFormat = f"Chapter {nwHeadFmt.CH_WORD}, Scene {nwHeadFmt.SC_NUM} - {nwHeadFmt.TITLE}"

View File

@@ -733,7 +733,7 @@ def testFmtToOdt_ConvertParagraphs(mockGUI):
'<office:text>'
'<text:h text:style-name="Heading_20_2" text:outline-level="2">Scene</text:h>'
'<text:p text:style-name="P7">Regular paragraph</text:p>'
'<text:p text:style-name="Text_20_body">with<text:line-break />break</text:p>'
'<text:p text:style-name="P7">with<text:line-break />break</text:p>'
'<text:p text:style-name="Text_20_body">Left Align</text:p>'
'</office:text>'
)

View File

@@ -25,14 +25,15 @@ import pytest
from PyQt6.QtGui import QFont, QTextBlock, QTextCharFormat, QTextCursor
from novelwriter import CONFIG
from novelwriter.constants import nwUnicode
from novelwriter.constants import nwHeadFmt, nwUnicode
from novelwriter.core.project import NWProject
from novelwriter.enum import nwComment
from novelwriter.formats.shared import BlockFmt, BlockTyp, TextDocumentTheme
from novelwriter.formats.toqdoc import ToQTextDocument
from novelwriter.types import (
QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignLeft, QtAlignRight,
QtPageBreakAfter, QtTransparent, QtVAlignNormal, QtVAlignSub, QtVAlignSuper
QtPageBreakAfter, QtPageBreakAuto, QtPageBreakBefore, QtTransparent,
QtVAlignNormal, QtVAlignSub, QtVAlignSuper
)
THEME = TextDocumentTheme()
@@ -54,6 +55,11 @@ def testFmtToQTextDocument_ConvertHeaders(mockGUI):
doc._isNovel = True
doc._isFirst = True
# Add a line break in chapter header format, see #2415
doc.setChapterFormat(f"{nwHeadFmt.CH_NUM}{nwHeadFmt.BR}{nwHeadFmt.TITLE}")
# Populate
doc._text = (
"#! Title\n"
"# Partition\n"
@@ -63,12 +69,13 @@ def testFmtToQTextDocument_ConvertHeaders(mockGUI):
)
doc.tokenizeText()
doc.doConvert()
assert doc.document.blockCount() == 5
assert doc.document.blockCount() == 6
# Title
block = doc.document.findBlockByNumber(0)
assert block.text() == "Title"
bFmt = block.blockFormat()
assert bFmt.pageBreakPolicy() == QtPageBreakAuto # Expected on first title
assert bFmt.topMargin() == doc._mHead[BlockTyp.TITLE][0]
assert bFmt.bottomMargin() == doc._mHead[BlockTyp.TITLE][1]
cFmt = charFmtInBlock(block, 1)
@@ -87,10 +94,23 @@ def testFmtToQTextDocument_ConvertHeaders(mockGUI):
assert cFmt.fontPointSize() == doc._sHead[BlockTyp.PART]
assert cFmt.foreground().color() == THEME.head
# Chapter
# Chapter, Line 1
block = doc.document.findBlockByNumber(2)
assert block.text() == "1"
bFmt = block.blockFormat()
assert bFmt.pageBreakPolicy() == QtPageBreakBefore
assert bFmt.topMargin() == doc._mHead[BlockTyp.HEAD1][0]
assert bFmt.bottomMargin() == doc._mHead[BlockTyp.HEAD1][1]
cFmt = charFmtInBlock(block, 1)
assert cFmt.fontWeight() == QFont.Weight.Bold
assert cFmt.fontPointSize() == doc._sHead[BlockTyp.HEAD1]
assert cFmt.foreground().color() == THEME.head
# Chapter, Line 2
block = doc.document.findBlockByNumber(3)
assert block.text() == "Chapter"
bFmt = block.blockFormat()
assert bFmt.pageBreakPolicy() == QtPageBreakAuto # Important! See #2415
assert bFmt.topMargin() == doc._mHead[BlockTyp.HEAD1][0]
assert bFmt.bottomMargin() == doc._mHead[BlockTyp.HEAD1][1]
cFmt = charFmtInBlock(block, 1)
@@ -99,9 +119,10 @@ def testFmtToQTextDocument_ConvertHeaders(mockGUI):
assert cFmt.foreground().color() == THEME.head
# Scene
block = doc.document.findBlockByNumber(3)
block = doc.document.findBlockByNumber(4)
assert block.text() == "Scene"
bFmt = block.blockFormat()
assert bFmt.pageBreakPolicy() == QtPageBreakAuto
assert bFmt.topMargin() == doc._mHead[BlockTyp.HEAD2][0]
assert bFmt.bottomMargin() == doc._mHead[BlockTyp.HEAD2][1]
cFmt = charFmtInBlock(block, 1)
@@ -110,9 +131,10 @@ def testFmtToQTextDocument_ConvertHeaders(mockGUI):
assert cFmt.foreground().color() == THEME.head
# Section
block = doc.document.findBlockByNumber(4)
block = doc.document.findBlockByNumber(5)
assert block.text() == "Section"
bFmt = block.blockFormat()
assert bFmt.pageBreakPolicy() == QtPageBreakAuto
assert bFmt.topMargin() == doc._mHead[BlockTyp.HEAD3][0]
assert bFmt.bottomMargin() == doc._mHead[BlockTyp.HEAD3][1]
cFmt = charFmtInBlock(block, 1)

View File

@@ -22,13 +22,16 @@ from __future__ import annotations
import argparse
import datetime
import os
import shutil
import subprocess
import sys
from pathlib import Path
from utils.common import (
ROOT_DIR, SETUP_DIR, appdataXml, copyPackageFiles, copySourceCode,
extractVersion, makeCheckSum, toUpload, writeFile
extractVersion, freshFolder, makeCheckSum, removeRedundantQt, systemCall,
toUpload, writeFile
)
@@ -49,115 +52,87 @@ def appImage(args: argparse.Namespace) -> None:
print("")
print("Build AppImage")
print("==============")
print("")
print("="*120)
linuxTag = args.linux_tag
pythonVer = args.python_version
mLinux = args.linux
mArch = args.arch
pyVer = args.python
# Version Info
# ============
pkgVers, _, relDate = extractVersion()
relDate = datetime.datetime.strptime(relDate, "%Y-%m-%d")
print("")
# Set Up Folder
# =============
bldDir = ROOT_DIR / "dist_appimage"
bldPkg = f"novelwriter_{pkgVers}"
bldPkg = f"novelwriter-{pkgVers}-{mArch}"
bldImg = f"{bldPkg}.AppImage"
outDir = bldDir / bldPkg
imgDir = bldDir / "appimage"
# Set Up Folders
# ==============
appDir = bldDir / f"novelWriter-{mArch}"
bldDir.mkdir(exist_ok=True)
if outDir.exists():
print("Removing old build files ...")
print("")
shutil.rmtree(outDir)
outDir.mkdir()
if imgDir.exists():
print("Removing old build metadata files ...")
print("")
shutil.rmtree(imgDir)
imgDir.mkdir()
freshFolder(outDir)
freshFolder(imgDir)
freshFolder(appDir)
# Remove old AppImages
if images := bldDir.glob("*.AppImage"):
print("Removing old AppImages")
print("")
for image in images:
image.unlink()
# Copy novelWriter Source
# =======================
print("Copying novelWriter source ...")
print("")
copySourceCode(outDir)
print("")
print("Copying or generating additional files ...")
print("")
copyPackageFiles(outDir)
# Write Metadata
# ==============
writeFile(imgDir / "novelwriter.appdata.xml", appdataXml())
print("Wrote: novelwriter.appdata.xml")
writeFile(imgDir / "requirements.txt", str(outDir))
writeFile(imgDir / "entrypoint.sh", (
'#! /bin/bash \n'
# f"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{APPDIR}}/usr/lib/{mArch}-linux-gnu/\n"
'{{ python-executable }} -sE ${APPDIR}/opt/python{{ python-version }}/bin/novelwriter "$@"'
))
print("Wrote: entrypoint.sh")
writeFile(imgDir / "requirements.txt", str(outDir))
print("Wrote: requirements.txt")
shutil.copyfile(SETUP_DIR / "data" / "novelwriter.desktop", imgDir / "novelwriter.desktop")
print("Copied: novelwriter.desktop")
shutil.copyfile(SETUP_DIR / "icons" / "novelwriter.svg", imgDir / "novelwriter.svg")
print("Copied: novelwriter.svg")
shutil.copyfile(
SETUP_DIR / "data" / "hicolor" / "256x256" / "apps" / "novelwriter.png",
imgDir / "novelwriter.png"
)
shutil.copyfile(SETUP_DIR / "icons" / "novelwriter.png", imgDir / "novelwriter.png")
print("Copied: novelwriter.png")
# Build AppImage
# ==============
# Build AppDir
systemCall([
sys.executable, "-m", "python_appimage", "build", "app", "--no-packaging",
"-l", f"{mLinux}_{mArch}", "-p", pyVer, "appimage"
], cwd=bldDir)
try:
subprocess.call([
sys.executable, "-m", "python_appimage", "build", "app",
"-l", linuxTag, "-p", pythonVer, "appimage"
], cwd=bldDir)
except Exception as exc:
print("AppImage build: FAILED")
print("")
print(str(exc))
print("")
sys.exit(1)
# Copy Libraries
libPath = Path(f"/usr/lib/{mArch}-linux-gnu")
siteDir = appDir / "opt" / f"python{pyVer}" / "lib" / f"python{pyVer}" / "site-packages"
qt6Lib = siteDir / "PyQt6" / "Qt6" / "lib"
shutil.copyfile(libPath / "libxcb-cursor.so.0", qt6Lib / "libxcb-cursor.so.0")
bldFile = list(bldDir.glob("*.AppImage"))[0]
outFile = bldDir / f"novelWriter-{pkgVers}.AppImage"
bldFile.rename(outFile)
shaFile = makeCheckSum(outFile.name, cwd=bldDir)
# Remove Redundant
removeRedundantQt(siteDir)
toUpload(outFile)
# Build Image
appToolExec = os.environ.get("APPIMAGE_TOOL_EXEC", "appimagetool")
env = os.environ.copy()
env["ARCH"] = mArch
systemCall([
appToolExec, "--no-appstream", "--updateinformation",
f"gh-releases-zsync|vkbo|novelwriter|latest|novelwriter-*-{mArch}.AppImage.zsync",
str(appDir), bldImg
], cwd=bldDir, env=env)
updFile = bldDir / f"{bldImg}.zsync"
bldFile = bldDir / bldImg
shaFile = makeCheckSum(bldFile.name, cwd=bldDir)
toUpload(bldFile)
toUpload(updFile)
toUpload(shaFile)
return

View File

@@ -24,12 +24,11 @@ import argparse
import datetime
import email.utils
import shutil
import subprocess
import sys
from utils.common import (
ROOT_DIR, SETUP_DIR, checkAssetsExist, copyPackageFiles, copySourceCode,
extractVersion, makeCheckSum, toUpload, writeFile
extractVersion, makeCheckSum, systemCall, toUpload, writeFile
)
SIGN_KEY = "D6A9F6B8F227CF7C6F6D1EE84DBBE4B734B0BD08"
@@ -134,10 +133,10 @@ def makeDebianPackage(
signArgs = [f"-k{signKey}"]
if sourceBuild:
subprocess.call(["debuild", "-S", *signArgs], cwd=outDir)
systemCall(["debuild", "-S", *signArgs], cwd=outDir)
toUpload(bldDir / f"{bldPkg}.tar.xz")
else:
subprocess.call(["dpkg-buildpackage", *signArgs], cwd=outDir)
systemCall(["dpkg-buildpackage", *signArgs], cwd=outDir)
shutil.copyfile(bldDir / f"{bldPkg}.tar.xz", bldDir / f"{bldPkg}.debian.tar.xz")
toUpload(bldDir / f"{bldPkg}.debian.tar.xz")
toUpload(bldDir / f"{bldPkg}_all.deb")
@@ -185,6 +184,7 @@ def launchpad(args: argparse.Namespace) -> None:
("24.04", "noble"),
("24.10", "oracular"),
("25.04", "plucky"),
("25.10", "questing"),
]
print("Building Ubuntu packages for:")

View File

@@ -23,14 +23,16 @@ from __future__ import annotations
import argparse
import compileall
import shutil
import subprocess
import sys
import urllib.request
import zipfile
from pathlib import Path
from utils.common import ROOT_DIR, SETUP_DIR, copySourceCode, extractVersion, readFile, writeFile
from utils.common import (
ROOT_DIR, SETUP_DIR, copySourceCode, extractVersion, readFile,
removeRedundantQt, systemCall, writeFile
)
def prepareCode(outDir: Path) -> None:
@@ -86,99 +88,11 @@ def embedPython(bldDir: Path, outDir: Path) -> None:
def installRequirements(libDir: Path) -> None:
"""Install dependencies."""
print("Install dependencies ...")
try:
subprocess.call([
sys.executable, "-m",
"pip", "install", "-r", "requirements.txt", "--target", str(libDir)
])
except Exception as exc:
print("Failed with error:")
print(str(exc))
sys.exit(1)
systemCall([
sys.executable, "-m", "pip", "install", "-r", "requirements.txt", "--target", libDir
])
print("Done")
print("")
return
def removeRedundantQt(libDir: Path) -> None:
"""Delete Qt files that are not needed"""
def unlinkIfFound(file: Path) -> None:
if file.is_file():
file.unlink()
print(f"Deleted: {file}")
def deleteFolder(folder: Path) -> None:
if folder.is_dir():
shutil.rmtree(folder)
print(f"Deleted: {folder}")
def unlinkIfPrefix(folder: Path, prefix: tuple[str, ...]) -> None:
if folder.is_dir():
for item in folder.iterdir():
if item.name.startswith(prefix):
if item.is_file():
unlinkIfFound(item)
elif item.is_dir():
deleteFolder(item)
print("Deleting Redundant Files")
print("========================")
print("")
pyQt6Dir = libDir / "PyQt6"
bindDir = libDir / "PyQt6" / "bindings"
qt6Dir = libDir / "PyQt6" / "Qt6"
binDir = libDir / "PyQt6" / "Qt6" / "bin"
plugDir = libDir / "PyQt6" / "Qt6" / "plugins"
qmDir = libDir / "PyQt6" / "Qt6" / "translations"
dictDir = libDir / "enchant" / "data" / "mingw64" / "share" / "enchant" / "hunspell"
for item in dictDir.iterdir():
if not item.name.startswith(("en_GB", "en_US")):
unlinkIfFound(item)
for item in qmDir.iterdir():
if not item.name.startswith("qtbase"):
unlinkIfFound(item)
bulkDel = ("QtQml", "Qt6Qml", "QtQuick", "Qt6Quick")
unlinkIfPrefix(pyQt6Dir, bulkDel)
unlinkIfPrefix(bindDir, bulkDel)
unlinkIfPrefix(binDir, bulkDel)
delQt6 = [
"Qt6Bluetooth", "Qt6DBus", "Qt6Designer", "Qt6Help", "Qt6Multimedia",
"Qt6MultimediaWidgets", "Qt6Network", "Qt6Nfc", "Qt6OpenGL", "Qt6Positioning",
"Qt6PositioningQuick", "Qt6Sensors", "Qt6SerialPort", "Qt6Sql", "Qt6Test",
"Qt6TextToSpeech", "Qt6WebChannel", "Qt6WebSockets", "Qt6Xml",
]
for item in delQt6:
qtItem = item.replace("Qt6", "Qt")
unlinkIfFound(binDir / f"{item}.dll")
unlinkIfFound(pyQt6Dir / f"{qtItem}.pyd")
unlinkIfFound(pyQt6Dir / f"{qtItem}.pyi")
deleteFolder(bindDir / qtItem)
delList = [
binDir / "opengl32sw.dll",
qt6Dir / "qml",
plugDir / "renderers",
plugDir / "sensors",
plugDir / "sqldrivers",
plugDir / "texttospeech",
plugDir / "webview",
]
for item in delList:
unlinkIfFound(item)
deleteFolder(item)
print("Done")
print("")
return
@@ -238,12 +152,7 @@ def main(args: argparse.Namespace) -> None:
writeFile(ROOT_DIR / "setup.iss", issData)
print("")
try:
subprocess.call(["iscc", "setup.iss"])
except Exception as exc:
print("Inno Setup failed with error:")
print(str(exc))
sys.exit(1)
systemCall(["iscc", "setup.iss"])
print("")
print("Done")

View File

@@ -22,6 +22,7 @@ from __future__ import annotations
import shutil
import subprocess
import sys
from pathlib import Path
@@ -50,11 +51,11 @@ def extractVersion(beQuiet: bool = False) -> tuple[str, str, str]:
if aLine.startswith("__date__"):
relDate = getValue(aLine)
except Exception as exc:
print(f"Could not read file: {initFile}")
print(str(exc))
print(f"Could not read file: {initFile}", flush=True)
print(str(exc), flush=True)
if not beQuiet:
print(f"novelWriter version: {numVers} ({hexVers}) at {relDate}")
print(f"novelWriter version: {numVers} ({hexVers}) at {relDate}", flush=True)
return numVers, hexVers, relDate
@@ -77,16 +78,16 @@ def copySourceCode(dst: Path) -> None:
for item in src.glob("**/*"):
relSrc = item.relative_to(ROOT_DIR)
if item.suffix in (".pyc", ".pyo"):
print(f"Ignore: {relSrc}")
print("Ignored:", relSrc, flush=True)
continue
if item.parent.is_dir() and item.parent.name != "__pycache__":
dstDir = dst / relSrc.parent
if not dstDir.exists():
dstDir.mkdir(parents=True)
print(f"Folder: {dstDir}")
print("Created:", dstDir.relative_to(ROOT_DIR), flush=True)
if item.is_file():
shutil.copyfile(item, dst / relSrc)
print(f"Copied: {dst / relSrc}")
print("Copied:", relSrc, flush=True)
return
@@ -95,26 +96,23 @@ def copyPackageFiles(dst: Path, setupPy: bool = False) -> None:
copyFiles = ["LICENSE.md", "CREDITS.md", "pyproject.toml"]
for copyFile in copyFiles:
shutil.copyfile(copyFile, dst / copyFile)
print(f"Copied: {copyFile}")
print("Copied:", copyFile, flush=True)
writeFile(dst / "MANIFEST.in", (
"include LICENSE.md\n"
"include CREDITS.md\n"
"recursive-include novelwriter/assets *\n"
))
print("Wrote: MANIFEST.in")
if setupPy:
writeFile(dst / "setup.py", (
"import setuptools\n"
"setuptools.setup()\n"
))
print("Wrote: setup.py")
text = readFile(ROOT_DIR / "pyproject.toml")
text = text.replace("setup/description_pypi.md", "data/description_short.txt")
writeFile(dst / "pyproject.toml", text)
print("Wrote: pyproject.toml")
return
@@ -139,10 +137,10 @@ def makeCheckSum(sumFile: str, cwd: Path | None = None) -> str:
shaFile = cwd / f"{sumFile}.sha256"
with open(shaFile, mode="w", encoding="utf-8") as fOut:
subprocess.call(["shasum", "-a", "256", sumFile], stdout=fOut, cwd=cwd)
print(f"SHA256 Sum: {shaFile}")
print(f"SHA256 Sum: {shaFile}", flush=True)
except Exception as exc:
print("Could not generate sha256 file")
print(str(exc))
print("Could not generate sha256 file", flush=True)
print(str(exc), flush=True)
return ""
return str(shaFile)
@@ -156,17 +154,17 @@ def checkAssetsExist() -> bool:
sampleZip = ROOT_DIR / "novelwriter" / "assets" / "sample.zip"
if sampleZip.is_file():
print(f"Found: {sampleZip}")
print(f"Found: {sampleZip}", flush=True)
hasSample = True
pdfManual = ROOT_DIR / "novelwriter" / "assets" / "manual.pdf"
if pdfManual.is_file():
print(f"Found: {pdfManual}")
print(f"Found: {pdfManual}", flush=True)
hasManual = True
i18nAssets = ROOT_DIR / "novelwriter" / "assets" / "i18n"
if len(list(i18nAssets.glob("*.qm"))) > 0:
print(f"Found: {i18nAssets}/*.qm")
print(f"Found: {i18nAssets}/*.qm", flush=True)
hasQmData = True
return hasSample and hasManual and hasQmData
@@ -188,4 +186,93 @@ def readFile(file: Path) -> str:
def writeFile(file: Path, text: str) -> int:
"""Write string to file."""
return file.write_text(text, encoding="utf-8")
result = file.write_text(text, encoding="utf-8")
print("Wrote:", file.relative_to(ROOT_DIR), flush=True)
return result
def freshFolder(path: Path) -> None:
"""Make sure a folder exists and is empty."""
if path.exists():
print("Removing:", str(path), flush=True)
shutil.rmtree(path)
path.mkdir()
return
def systemCall(cmd: list, cwd: Path | str | None = None, env: dict | None = None) -> int:
"""Make a system call using subprocess."""
if isinstance(cwd, Path):
cwd = str(cwd)
try:
code = subprocess.call([str(c) for c in cmd], cwd=cwd, env=env)
except Exception as exc:
print("ERROR:", str(exc), flush=True)
sys.exit(1)
return code
def removeRedundantQt(qtBase: Path) -> None:
"""Delete Qt files that are not needed"""
def unlinkIfFound(file: Path) -> None:
if file.is_file():
file.unlink()
print("Deleted:", file.relative_to(ROOT_DIR), flush=True)
def deleteFolder(folder: Path) -> None:
if folder.is_dir():
shutil.rmtree(folder)
print("Deleted:", folder.relative_to(ROOT_DIR), flush=True)
def unlinkIfPrefix(folder: Path, prefix: tuple[str, ...]) -> None:
if folder.is_dir():
for item in folder.iterdir():
if item.name.startswith(prefix):
if item.is_file():
unlinkIfFound(item)
elif item.is_dir():
deleteFolder(item)
print("Deleting redundant files ...")
pyQt6Dir = qtBase / "PyQt6"
bindDir = qtBase / "PyQt6" / "bindings"
qt6Dir = qtBase / "PyQt6" / "Qt6"
binDir = qtBase / "PyQt6" / "Qt6" / "bin"
libDir = qtBase / "PyQt6" / "Qt6" / "lib"
plugDir = qtBase / "PyQt6" / "Qt6" / "plugins"
qmDir = qtBase / "PyQt6" / "Qt6" / "translations"
dictDir = qtBase / "enchant" / "data" / "mingw64" / "share" / "enchant" / "hunspell"
# Prune Dictionaries
if dictDir.exists():
for item in dictDir.iterdir():
if not item.name.startswith(("en_GB", "en_US")):
unlinkIfFound(item)
# Prune Translations
for item in qmDir.iterdir():
if not item.name.startswith("qtbase"):
unlinkIfFound(item)
# Delete Modules
modules = [
"Qt6Qml", "Qt6Quick", "Qt6Bluetooth", "Qt6Nfc",
"Qt6Sensors", "Qt6SerialPort", "Qt6Test",
]
modules.extend([x.replace("Qt6", "Qt") for x in modules])
modules.extend([f"lib{x}" for x in modules])
modules = tuple(modules)
unlinkIfPrefix(pyQt6Dir, modules)
unlinkIfPrefix(bindDir, modules)
unlinkIfPrefix(binDir, modules)
unlinkIfPrefix(libDir, modules)
# Other Files
deleteFolder(qt6Dir / "qml")
deleteFolder(plugDir / "qmlls")
deleteFolder(plugDir / "qmllint")
return

View File

@@ -25,7 +25,7 @@ import os
import shutil
import subprocess
from utils.common import ROOT_DIR
from utils.common import ROOT_DIR, systemCall
def updateDocsTranslationSources(args: argparse.Namespace) -> None:
@@ -40,7 +40,7 @@ def updateDocsTranslationSources(args: argparse.Namespace) -> None:
locsDir.mkdir(exist_ok=True)
print("Generating POT Files")
subprocess.call(["make", "gettext"], cwd=docsDir)
systemCall(["make", "gettext"], cwd=docsDir)
print("")
lang = args.lang
@@ -55,7 +55,7 @@ def updateDocsTranslationSources(args: argparse.Namespace) -> None:
print("")
for code in update:
subprocess.call(["sphinx-intl", "update", "-p", "build/gettext", "-l", code], cwd=docsDir)
systemCall(["sphinx-intl", "update", "-p", "build/gettext", "-l", code], cwd=docsDir)
print("")
print("Done")