diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ab12a9d4..67a0dc5ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +### [4.3.7] - 25 November 2024 + +#### Fixed + +* Fixed forms not accepting decimal values for extra fields (PR #554) +* Fixed cross-references not working when the reference name contained spaces (PR #556) + ## [4.3.6] - 14 November 2024 ### Added diff --git a/VERSION b/VERSION index 8865cd4d6..bbc23a358 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -v4.3.6 -14 November 2024 +v4.3.7 +25 November 2024 diff --git a/config/settings/base.py b/config/settings/base.py index fa7fcc532..b2e159d92 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -11,9 +11,9 @@ # 3rd Party Libraries import environ -__version__ = "4.3.6" +__version__ = "4.3.7" VERSION = __version__ -RELEASE_DATE = "14 November 2024" +RELEASE_DATE = "25 November 2024" ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent APPS_DIR = ROOT_DIR / "ghostwriter" diff --git a/ghostwriter/modules/reportwriter/richtext/docx.py b/ghostwriter/modules/reportwriter/richtext/docx.py index f1605cac2..35ee07910 100644 --- a/ghostwriter/modules/reportwriter/richtext/docx.py +++ b/ghostwriter/modules/reportwriter/richtext/docx.py @@ -117,13 +117,14 @@ def _tag_h(self, el, **kwargs): run = heading_paragraph.runs[0] tag = run._r start = docx.oxml.shared.OxmlElement("w:bookmarkStart") - start.set(docx.oxml.ns.qn("w:id"), "0") + start.set(docx.oxml.ns.qn("w:id"), str(self.current_bookmark_id)) start.set(docx.oxml.ns.qn("w:name"), el.attrs["id"]) tag.append(start) end = docx.oxml.shared.OxmlElement("w:bookmarkEnd") - end.set(docx.oxml.ns.qn("w:id"), "0") + end.set(docx.oxml.ns.qn("w:id"), str(self.current_bookmark_id)) end.set(docx.oxml.ns.qn("w:name"), el.attrs["id"]) tag.append(end) + self.current_bookmark_id += 1 tag_h1 = _tag_h tag_h2 = _tag_h @@ -296,6 +297,7 @@ def __init__( self.title_case_exceptions = title_case_exceptions self.border_color_width = border_color_width self.plural_acronym_pattern = re.compile(r"^[^a-z]+(:?s|'s)$") + self.current_bookmark_id = 1000 # Hopefully won't conflict with templates def text(self, el, *, par=None, **kwargs): if par is not None and getattr(par, "_gw_is_caption", False): @@ -374,8 +376,8 @@ def make_caption(self, par, label: str, ref: str | None = None): # Start a bookmark run with the figure label p = par._p bookmark_start = OxmlElement("w:bookmarkStart") - bookmark_start.set(qn("w:name"), ref) - bookmark_start.set(qn("w:id"), "0") + bookmark_start.set(qn("w:name"), ref.replace(" ", "_")) + bookmark_start.set(qn("w:id"), str(self.current_bookmark_id)) p.append(bookmark_start) # Add the figure label @@ -414,9 +416,11 @@ def make_caption(self, par, label: str, ref: str | None = None): # End the bookmark after the number p = par._p bookmark_end = OxmlElement("w:bookmarkEnd") - bookmark_end.set(qn("w:id"), "0") + bookmark_end.set(qn("w:id"), str(self.current_bookmark_id)) p.append(bookmark_end) + self.current_bookmark_id += 1 + def make_evidence(self, par, evidence): file_path = settings.MEDIA_ROOT + "/" + evidence["path"] if not os.path.exists(file_path): @@ -528,7 +532,7 @@ def make_cross_ref(self, par, ref: str): run = par.add_run() r = run._r instrText = OxmlElement("w:instrText") - instrText.text = ' REF "_Ref{}" \\h '.format(ref.replace("\\", "\\\\").replace('"', '\\"')) + instrText.text = ' REF "_Ref{}" \\h '.format(ref.replace("\\", "\\\\").replace('"', '\\"').replace(" ", "_")) r.append(instrText) # An optional ``separate`` value to enforce a space between label and number