-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert ₀:$_0$ ... ₉:$_9$ #72
Comments
workaround @staticmethod
def uniCode2Latex(text:str)->str:
'''
converts unicode text to latex and
fixes UTF-8 chars for latex in a certain range:
₀:$_0$ ... ₉:$_9$
see https://github.com/phfaist/pylatexenc/issues/72
Args:
text(str): the string to fix
Return:
str: latex presentation of UTF-8 char
'''
for code in range(8320,8330):
text=text.replace(chr(code),f"$_{code-8320}$")
return unicode_to_latex(text) unit test def testUnicode2LatexWorkaround(self):
'''
test the uniCode2Latex conversion workaround
'''
debug=True
for code in range(8320,8330):
uc=chr(code)
latex=QueryResultDocumentation.uniCode2Latex(uc)
if debug:
print(f"{uc}→{latex}")
#self.assertTrue(latex.startswith("$_"))
unicode="À votre santé!"
latex=QueryResultDocumentation.uniCode2Latex(unicode)
if debug:
print(f"{unicode}→{latex}")
self.assertEqual("\\`A votre sant\\'e!",latex) |
result:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: