diff --git a/README.md b/README.md index eebd300..8dc2432 100644 --- a/README.md +++ b/README.md @@ -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/) @@ -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 @@ -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. diff --git a/VERSION b/VERSION index 57944bc..6c64365 100644 --- a/VERSION +++ b/VERSION @@ -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 diff --git a/dist/nv_yw7_v4.2.12.pyzw b/dist/nv_yw7_v4.2.12.pyzw deleted file mode 100644 index b4c4d5d..0000000 Binary files a/dist/nv_yw7_v4.2.12.pyzw and /dev/null differ diff --git a/dist/nv_yw7_v4.2.12.zip b/dist/nv_yw7_v4.2.12.zip deleted file mode 100644 index 8c2a849..0000000 Binary files a/dist/nv_yw7_v4.2.12.zip and /dev/null differ diff --git a/dist/nv_yw7_v4.2.13.pyzw b/dist/nv_yw7_v4.2.13.pyzw new file mode 100644 index 0000000..b1ad3a2 Binary files /dev/null and b/dist/nv_yw7_v4.2.13.pyzw differ diff --git a/dist/nv_yw7_v4.2.13.zip b/dist/nv_yw7_v4.2.13.zip new file mode 100644 index 0000000..696221f Binary files /dev/null and b/dist/nv_yw7_v4.2.13.zip differ diff --git a/docs/changelog.md b/docs/changelog.md index 079a678..bf25f48 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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. diff --git a/i18n/de.po b/i18n/de.po index 4151b5d..55af4e5 100644 --- a/i18n/de.po +++ b/i18n/de.po @@ -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" diff --git a/i18n/locale/de/LC_MESSAGES/nv_yw7.mo b/i18n/locale/de/LC_MESSAGES/nv_yw7.mo index c297e55..71b054b 100644 Binary files a/i18n/locale/de/LC_MESSAGES/nv_yw7.mo and b/i18n/locale/de/LC_MESSAGES/nv_yw7.mo differ diff --git a/i18n/messages.pot b/i18n/messages.pot index 9d0a539..a74f2b8 100644 --- a/i18n/messages.pot +++ b/i18n/messages.pot @@ -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 \n" "Language: LANGUAGE\n" diff --git a/src/nvyw7lib/xml_fixer.py b/src/nvyw7lib/xml_fixer.py index a3e2a00..200e30e 100644 --- a/src/nvyw7lib/xml_fixer.py +++ b/src/nvyw7lib/xml_fixer.py @@ -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 diff --git a/src/nvyw7lib/yw7_file.py b/src/nvyw7lib/yw7_file.py index 20a7c1d..8663e87 100644 --- a/src/nvyw7lib/yw7_file.py +++ b/src/nvyw7lib/yw7_file.py @@ -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('> '): + line = f"> {opening[tag]}{line.lstrip('> ')}" + 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 @@ -763,31 +790,7 @@ def replace_comment(match): xmlReplacements.append((f'[/lang={language}]', '')) #--- 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('> '): - line = f"> {opening[tag]}{line.lstrip('> ')}" - 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: diff --git a/tools/build.py b/tools/build.py index 85042ae..f47431c 100644 --- a/tools/build.py +++ b/tools/build.py @@ -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):