Skip to content
Snippets Groups Projects
Commit 4c12b1be authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Handling headings for annexes and some special characters (not finished)

parent 3a643710
No related branches found
No related tags found
No related merge requests found
...@@ -100,6 +100,11 @@ ff0c = 2c20 ...@@ -100,6 +100,11 @@ ff0c = 2c20
d7 = 78 d7 = 78
; Ligature "fi" ; Ligature "fi"
fb01 = 6669 fb01 = 6669
; "<="
f0fd = 3c3d
; "=>"
f0e0 = 3e3d
[media] [media]
......
...@@ -404,9 +404,23 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: ...@@ -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 pass # ignore a soft hyphen character which has no meaning in Markdown and zero-width
case 'sym': case 'sym':
_symError = f'unknown font+symbol: {element.attrib["{"+wns+"}font"]} - "{element.attrib["{"+wns+"}char"]}"' if inCell:
_print(f'[yellow]{_symError}') ch = element.attrib["{"+wns+"}char"]
_result += f'<mark>{_symError}</mark>' _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 # ignore deleted test
case 'del': case 'del':
...@@ -542,7 +556,7 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: ...@@ -542,7 +556,7 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion:
# Processing the document # Processing the document
lines:list[str] = [] lines:list[str] = []
imageIndex = 1 imageIndex = 1
isAnnex = False
for elem in docItems: for elem in docItems:
paragraphNr += 1 paragraphNr += 1
progress.update(processTask, advance = 1) progress.update(processTask, advance = 1)
...@@ -557,25 +571,33 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: ...@@ -557,25 +571,33 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion:
checkSameStyle(Style.normal, lambda:lines.append('')) checkSameStyle(Style.normal, lambda:lines.append(''))
lines.append(text) lines.append(text)
lines.append('') # Add empty line lines.append('') # Add empty line
continue
# Headers # 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) lines.extend(toHeader(style, text, 9))
# Annexes # Annexes
...@@ -663,6 +685,10 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: ...@@ -663,6 +685,10 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion:
if docConfig.generateToc: if docConfig.generateToc:
lines.append(_tocInsertPoint) lines.append(_tocInsertPoint)
# Check when TOC ends
if text.find("History"):
isAnnex = False
# Ignore & empty # Ignore & empty
elif style in docConfig.ignore: elif style in docConfig.ignore:
pass pass
...@@ -675,6 +701,7 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion: ...@@ -675,6 +701,7 @@ def processDocuments(documents:list[str], outDirectory:str, skipImageConversion:
lines.append(text) lines.append(text)
case 'Table': case 'Table':
rows:list[list[str]] = [] rows:list[list[str]] = []
nrRows = 0 nrRows = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment