mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
fix nbsp handling in latex
This commit is contained in:
parent
4c7f7a7c4b
commit
c394886af8
1 changed files with 3 additions and 2 deletions
|
@ -61,10 +61,11 @@ def _imgLink(col, latex, model):
|
||||||
|
|
||||||
def _latexFromHtml(col, latex):
|
def _latexFromHtml(col, latex):
|
||||||
"Convert entities and fix newlines."
|
"Convert entities and fix newlines."
|
||||||
|
# entitydefs defines nbsp as \xa0 instead of a standard space, so we
|
||||||
|
# replace it first
|
||||||
|
latex = latex.replace(" ", " ")
|
||||||
for match in re.compile("&([a-z]+);", re.IGNORECASE).finditer(latex):
|
for match in re.compile("&([a-z]+);", re.IGNORECASE).finditer(latex):
|
||||||
if match.group(1) in entitydefs:
|
if match.group(1) in entitydefs:
|
||||||
if match.group() == " ":
|
|
||||||
continue
|
|
||||||
latex = latex.replace(match.group(), entitydefs[match.group(1)])
|
latex = latex.replace(match.group(), entitydefs[match.group(1)])
|
||||||
latex = re.sub("<br( /)?>", "\n", latex)
|
latex = re.sub("<br( /)?>", "\n", latex)
|
||||||
# replace <div> etc with spaces
|
# replace <div> etc with spaces
|
||||||
|
|
Loading…
Reference in a new issue