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
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -100,6 +100,11 @@ ff0c = 2c20
d7 = 78
; Ligature "fi"
fb01 = 6669
; "<="
f0fd = 3c3d
; "=>"
f0e0 = 3e3d



[media]
+41 −14
Original line number Diff line number Diff line
@@ -404,6 +404,20 @@ 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':
						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>'
@@ -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