DOCX Input: Avoid nested <sup> tags for footnote references

Also avoid empty <sup> or <sub> tags.
This commit is contained in:
Kovid Goyal 2019-12-08 06:47:42 +05:30
parent f1ce7c0cf9
commit 08ca34e735
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -702,7 +702,13 @@ class Convert(object):
style = self.styles.resolve_run(run) style = self.styles.resolve_run(run)
if style.vert_align in {'superscript', 'subscript'}: if style.vert_align in {'superscript', 'subscript'}:
if ans.text or len(ans):
ans.tag = 'sub' if style.vert_align == 'subscript' else 'sup' ans.tag = 'sub' if style.vert_align == 'subscript' else 'sup'
try:
if ans[0].tag == 'a' and ans[0].get('class', 'noteref') and ans[0][0].tag == 'sup' and ans.tag == 'sup':
ans[0][0].tag = 'span'
except Exception:
pass
if style.lang is not inherit: if style.lang is not inherit:
lang = html_lang(style.lang) lang = html_lang(style.lang)
if lang is not None and lang != self.doc_lang: if lang is not None and lang != self.doc_lang: