Merge branch 'fix-replace-str' into 'master'

A further and more extensive fix to the fix in !359

See merge request openlp/openlp!360
This commit is contained in:
Tim Bentley 2021-09-07 11:44:26 +00:00
commit d83eec024b
1 changed files with 4 additions and 2 deletions

View File

@ -676,8 +676,10 @@ class OpenLyrics(object):
text = ''
# Convert lxml.objectify to lxml.etree representation.
string_lines = etree.tostring(lines)
# lxml 4.6.x or some recent version of libxml2 seems to add the left-over tags in
string_lines = string_lines.replace('</verse>', '').replace('</lyrics>', '').replace('</song>')
# lxml 4.6.x or some recent version of libxml2 seems to add the rest of the song to the string, so split on the
# closing verse tag, and then add it back in
string_lines, _ = string_lines.split(b'</lines>', 1)
string_lines += b'</lines>'
element = etree.XML(string_lines)
# OpenLyrics 0.8 uses <br/> for new lines. Append text from "lines" element to verse text.