Skip to content

Commit

Permalink
Prepare v4.2.13, compatible with novelibre 4.3
Browse files Browse the repository at this point in the history
- Refactor the code.
  • Loading branch information
peter88213 committed Sep 21, 2024
1 parent defad5a commit 06bb282
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 42 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Download the latest release](docs/img/download-button.png)](https://github.com/peter88213/nv_yw7/raw/main/dist/nv_yw7_v4.2.12.pyzw)
[![Download the latest release](docs/img/download-button.png)](https://github.com/peter88213/nv_yw7/raw/main/dist/nv_yw7_v4.2.13.pyzw)
[![Changelog](docs/img/changelog-button.png)](docs/changelog.md)
[![News](docs/img/news-button.png)](https://github.com/peter88213/novelibre/discussions/1)
[![Online help](docs/img/help-button.png)](docs/nv_yw7/)
Expand All @@ -20,10 +20,10 @@ The [novelibre](https://github.com/peter88213/novelibre/) Python program helps a

### Default: Executable Python zip archive

Download the latest release [nv_yw7_v4.2.12.pyzw](https://github.com/peter88213/nv_yw7/raw/main/dist/nv_yw7_v4.2.12.pyzw)
Download the latest release [nv_yw7_v4.2.13.pyzw](https://github.com/peter88213/nv_yw7/raw/main/dist/nv_yw7_v4.2.13.pyzw)

- Launch *nv_yw7_v4.2.12.pyzw* by double-clicking (Windows/Linux desktop),
- or execute `python nv_yw7_v4.2.12.pyzw` (Windows), resp. `python3 nv_yw7_v4.2.12.pyzw` (Linux) on the command line.
- Launch *nv_yw7_v4.2.13.pyzw* by double-clicking (Windows/Linux desktop),
- or execute `python nv_yw7_v4.2.13.pyzw` (Windows), resp. `python3 nv_yw7_v4.2.13.pyzw` (Linux) on the command line.

#### Important

Expand All @@ -39,9 +39,9 @@ the zip file.

### Alternative: Zip file

The package is also available in zip format: [nv_yw7_v4.2.12.zip](https://github.com/peter88213/nv_yw7/raw/main/dist/nv_yw7_v4.2.12.zip)
The package is also available in zip format: [nv_yw7_v4.2.13.zip](https://github.com/peter88213/nv_yw7/raw/main/dist/nv_yw7_v4.2.13.zip)

- Extract the *nv_yw7_v4.2.12* folder from the downloaded zipfile "nv_yw7_v4.2.12.zip".
- Extract the *nv_yw7_v4.2.13* folder from the downloaded zipfile "nv_yw7_v4.2.13.zip".
- Move into this new folder and launch *setup.pyw* by double-clicking (Windows/Linux desktop),
- or execute `python setup.pyw` (Windows), resp. `python3 setup.pyw` (Linux) on the command line.

Expand Down
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[LATEST]
version = 4.2.12
download_link = https://github.com/peter88213/nv_yw7/raw/main/dist/nv_yw7_v4.2.12.pyzw
version = 4.2.13
download_link = https://github.com/peter88213/nv_yw7/raw/main/dist/nv_yw7_v4.2.13.pyzw
Binary file removed dist/nv_yw7_v4.2.12.pyzw
Binary file not shown.
Binary file removed dist/nv_yw7_v4.2.12.zip
Binary file not shown.
Binary file added dist/nv_yw7_v4.2.13.pyzw
Binary file not shown.
Binary file added dist/nv_yw7_v4.2.13.zip
Binary file not shown.
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

## Changelog

### Version 4.2.13

- Refactor the code.

Compatibility: novelibre 4.3 API
Based on novxlib 4.6.7

### Version 4.2.12

- Refactor the XmlFixer code.
Expand Down
6 changes: 3 additions & 3 deletions i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#
msgid ""
msgstr ""
"Project-Id-Version: 4.2.12\n"
"POT-Creation-Date: 2024-09-20 22:41:05\n"
"PO-Revision-Date: 2024-09-20 22:41:05\n"
"Project-Id-Version: 4.2.13\n"
"POT-Creation-Date: 2024-09-21 18:39:35\n"
"PO-Revision-Date: 2024-09-21 18:39:35\n"
"Last-Translator: Peter Triesberger\n"
"Language: de\n"
"MIME-Version: 1.0\n"
Expand Down
Binary file modified i18n/locale/de/LC_MESSAGES/nv_yw7.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions i18n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#
msgid ""
msgstr ""
"Project-Id-Version: 4.2.12\n"
"POT-Creation-Date: 2024-09-20 22:41:05\n"
"Project-Id-Version: 4.2.13\n"
"POT-Creation-Date: 2024-09-21 18:39:35\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: LANGUAGE\n"
Expand Down
6 changes: 3 additions & 3 deletions src/nvyw7lib/xml_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
class XmlFixer(HTMLParser):
"""Event driven parser that accepts malformed XML."""

def __init__(self, formatTags):
def __init__(self, tags):
"""Set the format tags that must not overlap.
Positional arguments:
formatTags: set of str, e.g. ('em', 'strong')
tags: set of str, e.g. ('em', 'strong')
"""
super().__init__()
self._formatTags = formatTags
self._formatTags = tags
# set of formatting tags to consider
self._fixedXmlStr = []
# list of processed lines
Expand Down
53 changes: 28 additions & 25 deletions src/nvyw7lib/yw7_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,33 @@ def build_prjNote_subtree(xmlProjectnote, projectNote):

def _convert_to_novx(self, text):

def fix_multiline_formatting(text, tags):
newlines = []
lines = text.split('\n')
isOpen = {}
opening = {}
closing = {}
for tag in tags:
isOpen[tag] = False
opening[tag] = f'[{tag}]'
closing[tag] = f'[/{tag}]'
for line in lines:
for tag in tags:
if isOpen[tag]:
if line.startswith('&gt; '):
line = f"&gt; {opening[tag]}{line.lstrip('&gt; ')}"
else:
line = f'{opening[tag]}{line}'
isOpen[tag] = False
while line.count(opening[tag]) > line.count(closing[tag]):
line = f'{line}{closing[tag]}'
isOpen[tag] = True
while line.count(closing[tag]) > line.count(opening[tag]):
line = f'{opening[tag]}{line}'
line = line.replace(f'{opening[tag]}{closing[tag]}', '')
newlines.append(line)
return '\n'.join(newlines).rstrip()

def replace_note(match):
noteType = match.group(1)
self._noteCounter += 1
Expand Down Expand Up @@ -763,31 +790,7 @@ def replace_comment(match):
xmlReplacements.append((f'[/lang={language}]', '</span>'))

#--- Process markup reaching across linebreaks.
newlines = []
lines = text.split('\n')
isOpen = {}
opening = {}
closing = {}
for tag in tags:
isOpen[tag] = False
opening[tag] = f'[{tag}]'
closing[tag] = f'[/{tag}]'
for line in lines:
for tag in tags:
if isOpen[tag]:
if line.startswith('&gt; '):
line = f"&gt; {opening[tag]}{line.lstrip('&gt; ')}"
else:
line = f'{opening[tag]}{line}'
isOpen[tag] = False
while line.count(opening[tag]) > line.count(closing[tag]):
line = f'{line}{closing[tag]}'
isOpen[tag] = True
while line.count(closing[tag]) > line.count(opening[tag]):
line = f'{opening[tag]}{line}'
line = line.replace(f'{opening[tag]}{closing[tag]}', '')
newlines.append(line)
text = '\n'.join(newlines).rstrip()
text = fix_multiline_formatting(text, tags)

#--- Apply odt formating.
for nv, od in xmlReplacements:
Expand Down
2 changes: 1 addition & 1 deletion tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
sys.path.insert(0, f'{os.getcwd()}/../../novelibre/tools')
from package_builder import PackageBuilder

VERSION = '4.2.12'
VERSION = '4.2.13'


class PluginBuilder(PackageBuilder):
Expand Down

0 comments on commit 06bb282

Please # to comment.