mirror of
https://github.com/vale981/recommonmark
synced 2025-03-04 17:41:38 -05:00
Handle quotes in alt texts
A bit of a brute force solution, but the parser splits the attribute upon encountering a quote into multiple nodes. Walk through them, collect strings and drop them from further parsing.
This commit is contained in:
parent
816fc608e6
commit
6e1f4abba0
1 changed files with 7 additions and 1 deletions
|
@ -179,8 +179,14 @@ class CommonMarkParser(parsers.Parser):
|
|||
img_node['uri'] = mdnode.destination
|
||||
|
||||
if mdnode.first_child and mdnode.first_child.literal:
|
||||
img_node['alt'] = mdnode.first_child.literal
|
||||
content = [mdnode.first_child.literal]
|
||||
n = mdnode.first_child
|
||||
mdnode.first_child.literal = ''
|
||||
mdnode.first_child = mdnode.last_child = None
|
||||
while getattr(n, 'nxt'):
|
||||
n.nxt, n = None, n.nxt
|
||||
content.append(n.literal)
|
||||
img_node['alt'] = ''.join(content)
|
||||
|
||||
self.current_node.append(img_node)
|
||||
self.current_node = img_node
|
||||
|
|
Loading…
Add table
Reference in a new issue