diff --git a/config.ini b/config.ini index e7fe449beea548fb00fc1b27bec0a433084a21ca..1ed69a097bfd05710a863505dbeac2810c2e6a6f 100644 --- a/config.ini +++ b/config.ini @@ -100,6 +100,11 @@ ff0c = 2c20 d7 = 78 ; Ligature "fi" fb01 = 6669 +; "<=" +f0fd = 3c3d +; "=>" +f0e0 = 3e3d + [media] diff --git a/spec2md.py b/spec2md.py index dc2441470c1a7347c103308a89ad7c1f746081ab..20eb994492a3be2668fcca55d5e831c11d421117 100644 --- a/spec2md.py +++ b/spec2md.py @@ -404,9 +404,23 @@ 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>' + if inCell: + ch = element.attrib["{"+wns+"}char"] + _print(f'[yellow]: {ch} ') + + if not ch.isascii(): + _print(f'[yellow]: {ch}') + if (_ch := ord(ch)) in docConfig.characters: + if (rch := docConfig.characters[_ch]) == chr(0): + rch = '' + _result = rch + else: + _print( + f'[yellow]Non-ASCII character (consider to add a replacement in the config.ini file): "{ch}" / {ord(ch)} / {hex(ord(ch))}') + else: + _symError = f'unknown font+symbol: {element.attrib["{"+wns+"}font"]} - "{element.attrib["{"+wns+"}char"]}"' + _print(f'[yellow]{_symError}') + _result += f'<mark>{_symError}</mark>' # ignore deleted test case 'del': @@ -542,7 +556,7 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: # Processing the document lines:list[str] = [] imageIndex = 1 - + isAnnex = False for elem in docItems: paragraphNr += 1 progress.update(processTask, advance = 1) @@ -557,25 +571,33 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: checkSameStyle(Style.normal, lambda:lines.append('')) lines.append(text) lines.append('') # Add empty line - + continue + # Headers - elif style in docConfig.h1: + #print(f'{style} {text}') + # Check if annexes start + if text.find("Annex A") != -1: + isAnnex = True + elif text.find("History") != -1: + isAnnex = False + + if (style in docConfig.h1) and not isAnnex: lines.extend(toHeader(style, text, 1)) - elif style in docConfig.h2: + elif (style in docConfig.h2) and not isAnnex: lines.extend(toHeader(style, text, 2)) - elif style in docConfig.h3: + elif (style in docConfig.h3) and not isAnnex: lines.extend(toHeader(style, text, 3)) - elif style in docConfig.h4: + elif (style in docConfig.h4) and not isAnnex: lines.extend(toHeader(style, text, 4)) - elif style in docConfig.h5: + elif (style in docConfig.h5) and not isAnnex: lines.extend(toHeader(style, text, 5)) - elif style in docConfig.h6: + elif (style in docConfig.h6) and not isAnnex: lines.extend(toHeader(style, text, 6)) - elif style in docConfig.h7: + elif (style in docConfig.h7) and not isAnnex: lines.extend(toHeader(style, text, 7)) - elif style in docConfig.h8: + elif (style in docConfig.h8) and not isAnnex: lines.extend(toHeader(style, text, 8)) - elif style in docConfig.h9: + elif (style in docConfig.h9) and not isAnnex: lines.extend(toHeader(style, text, 9)) # Annexes @@ -663,6 +685,10 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: if docConfig.generateToc: lines.append(_tocInsertPoint) + # Check when TOC ends + if text.find("History"): + isAnnex = False + # Ignore & empty elif style in docConfig.ignore: pass @@ -675,6 +701,7 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: lines.append(text) + case 'Table': rows:list[list[str]] = [] nrRows = 0