From e0ababce3f58720f1666ef80610eddf7cf0d08c7 Mon Sep 17 00:00:00 2001 From: ankraft <an.kraft@gmail.com> Date: Fri, 1 Dec 2023 11:38:47 +0100 Subject: [PATCH] Fixed problem with symbol (non-unicode) character replacements --- config.ini | 7 +++++++ spec2md.py | 21 +++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config.ini b/config.ini index e7fe449..991a575 100644 --- a/config.ini +++ b/config.ini @@ -100,6 +100,13 @@ ff0c = 2c20 d7 = 78 ; Ligature "fi" fb01 = 6669 +; "<=" +f0fd = 3c3d +; "=>" +f0e0 = 3e3d +; "<=>" +f0df = 3c3d3e + [media] diff --git a/spec2md.py b/spec2md.py index b8a1da7..b4a82a1 100644 --- a/spec2md.py +++ b/spec2md.py @@ -402,9 +402,22 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: pass # ignore a soft hyphen character which has no meaning in Markdown and zero-width case 'sym': - _symError = f'unknown font+symbol: {element.attrib["{"+wns+"}font"]} - "{element.attrib["{"+wns+"}char"]}"' - _print(f'[yellow]{_symError}') - _result += f'<mark>{_symError}</mark>' + def _symError(ch:str) -> str: + nonlocal _result + _symError = f'unknown font+symbol: {element.attrib["{"+wns+"}font"]} - "{element.attrib["{"+wns+"}char"]} ({ch})"' + _print(f'[yellow]{_symError}') + _result += f'<mark>{_symError}</mark>' + try: + _ch = '????' + _ch = int(element.attrib["{"+wns+"}char"], 16) + if _ch in docConfig.characters: + if (rch := docConfig.characters[_ch]) == chr(0): + rch = '' + _result += rch + else: + _symError(_ch) + except ValueError as e: + _symError(_ch) # ignore deleted test case 'del': @@ -791,7 +804,7 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: for i in range(len(lines)): line = lines[i] if _captionMarker in line: - _print(f'[yellow]Unresolved figure caption : \[{i}] "{line}"') + _print(f'[yellow]Unresolved / unreferenced figure caption : \[{i}] "{line}"') # # Write produced Markdown file -- GitLab