[Sync] Kazimir fixing quotes inside links improved to work with begining of text
This commit is contained in:
1 parent
82abbed156
commit
7793830e60
1 file changed
+4
-5
@@ -45,6 +45,8 @@ def clean_tree(tree):
|
|||||||
|
|
||||||
|
|
||||||
def fix_links_quotes(tree):
|
def fix_links_quotes(tree):
|
||||||
|
safe = lambda x: x if x else ''
|
||||||
|
|
||||||
for link in tree.iterlinks():
|
for link in tree.iterlinks():
|
||||||
a = link[0]
|
a = link[0]
|
||||||
if a.tag != 'a':
|
if a.tag != 'a':
|
||||||
@@ -58,13 +60,10 @@ def fix_links_quotes(tree):
|
|||||||
a.text = a.text[1:-1]
|
a.text = a.text[1:-1]
|
||||||
|
|
||||||
# Move first quote out of A to the prefix
|
# Move first quote out of A to the prefix
|
||||||
a.getparent().text = a.getparent().text + quote[0]
|
a.getparent().text = safe(a.getparent().text) + quote[0]
|
||||||
|
|
||||||
# Move last quote out of A to the suffix
|
# Move last quote out of A to the suffix
|
||||||
if a.tail:
|
a.tail = quote[1] + safe(a.tail)
|
||||||
a.tail = quote[1] + a.tail
|
|
||||||
else:
|
|
||||||
a.tail = quote[1]
|
|
||||||
|
|
||||||
return tree
|
return tree
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user