dfxp2srt: Fix disappearing words after <span>s ( '<span>...</span> this-goes-missing' ). Ensure trailing whitespace/newlines are not added.
This commit is contained in:
parent
056c797523
commit
7db0a3d1bc
@ -1850,6 +1850,12 @@ def dfxp2srt(dfxp_data):
|
|||||||
'ttaf1': 'http://www.w3.org/2006/10/ttaf1',
|
'ttaf1': 'http://www.w3.org/2006/10/ttaf1',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def text_or_empty(v):
|
||||||
|
str = str_or_none(v, '')
|
||||||
|
return '' if not re.search(r'[^\s]',str,re.DOTALL) else str
|
||||||
|
|
||||||
|
|
||||||
def parse_node(node):
|
def parse_node(node):
|
||||||
str_or_empty = functools.partial(str_or_none, default='')
|
str_or_empty = functools.partial(str_or_none, default='')
|
||||||
|
|
||||||
@ -1859,7 +1865,7 @@ def dfxp2srt(dfxp_data):
|
|||||||
if child.tag in (_x('ttml:br'), _x('ttaf1:br'), 'br'):
|
if child.tag in (_x('ttml:br'), _x('ttaf1:br'), 'br'):
|
||||||
out += '\n' + str_or_empty(child.tail)
|
out += '\n' + str_or_empty(child.tail)
|
||||||
elif child.tag in (_x('ttml:span'), _x('ttaf1:span'), 'span'):
|
elif child.tag in (_x('ttml:span'), _x('ttaf1:span'), 'span'):
|
||||||
out += str_or_empty(parse_node(child))
|
out += str_or_empty(parse_node(child)) + text_or_empty(child.tail)
|
||||||
else:
|
else:
|
||||||
out += str_or_empty(xml.etree.ElementTree.tostring(child))
|
out += str_or_empty(xml.etree.ElementTree.tostring(child))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user