From a9d8f5a51353c463aabb4d888873a5e49d17b0a5 Mon Sep 17 00:00:00 2001 From: Laurence Warne Date: Sun, 14 Jan 2024 14:00:06 +0000 Subject: [PATCH] Fix issue with code blocks not copying due to ET parser issue Co-authored-by: daru --- code_select.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code_select.py b/code_select.py index b095d62..8e8f643 100755 --- a/code_select.py +++ b/code_select.py @@ -19,7 +19,12 @@ else: def parse_text_content(element): - root = ET.fromstring(element) + # https://stackoverflow.com/a/35591507/15245191 + magic = ''' + ]>''' + root = ET.fromstring(magic + element) text = ET.tostring(root, encoding="unicode", method="text") text = html.unescape(text) return text