Skip to content
Snippets Groups Projects
Commit c43a6753 authored by Andreas Kraft's avatar Andreas Kraft
Browse files

Support for html character entities when replacing certain characters

parent 47f3f6cb
No related branches found
No related tags found
No related merge requests found
...@@ -90,11 +90,26 @@ ignore = toc 1, toc 2, toc 3, toc 4, toc 5, toc 6, toc 7, toc 8, toc 9 ...@@ -90,11 +90,26 @@ ignore = toc 1, toc 2, toc 3, toc 4, toc 5, toc 6, toc 7, toc 8, toc 9
; The characters to be replaced and the characters that make the ; The characters to be replaced and the characters that make the
; replacement string must be specified as hex values ; replacement string must be specified as hex values
; To remove a character from the file set it to 00 (2 zeros) ; To remove a character from the file set it to 00 (2 zeros)
;
; The following are some common characters that can be replaced as well.
; Registered trademark (®) — (`®`)
; Trademark (™) — (`™`)
; Euro (€) — (`€`)
; Left arrow (←) — (`←`)
; Up arrow (↑) — (`↑`)
; Right arrow (→) — (`→`)
; Down arrow (↓) — (`↓`)
; Degree (°) — (`°`)
; Pi (π) — (`π`)
; "(c)" ; "(c)"
a9 = 286329 ; a9 = 286329
a9 = ©
; "(R)" ; "(R)"
ae = 285229 ; ae = 285229
ae = ®
; space ; space
a0 = 20 a0 = 20
; double quote ; double quote
......
...@@ -192,8 +192,16 @@ class DocumentConfiguration(object): ...@@ -192,8 +192,16 @@ class DocumentConfiguration(object):
self.generateToc = config.getboolean('toc', 'generateToc', fallback = False) self.generateToc = config.getboolean('toc', 'generateToc', fallback = False)
# characters # characters
self.characters = { int(c, 16) : binascii.unhexlify(config.get('characters', c)).decode('utf-8') # type: ignore [attr-defined] # self.characters = { int(c, 16) : binascii.unhexlify(config.get('characters', c)).decode('utf-8') # type: ignore [attr-defined]
for c in config['characters'] } # for c in config['characters'] }
self.characters = {}
for c,v in config['characters'].items():
if v.startswith('&'):
# HTML entity
self.characters[int(c, 16)] = v
else:
# Unicode character
self.characters[int(c, 16)] = binascii.unhexlify(config.get('characters', c)).decode('utf-8') # type: ignore [attr-defined]
# Media & Converter # Media & Converter
self.emfConverterPng = config.get('media', 'emfConverterPng', fallback = None) self.emfConverterPng = config.get('media', 'emfConverterPng', fallback = None)
......
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