File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 7
7
8
8
from __future__ import absolute_import
9
9
10
+ import re
11
+ import sys
10
12
from lxml import etree
11
13
12
14
from .ns import NamespacePrefixedTag , nsmap
18
20
oxml_parser .set_element_class_lookup (element_class_lookup )
19
21
20
22
23
+ def remove_hyperlink_tags (xml ):
24
+ if (sys .version_info > (3 , 0 )):
25
+ xml = xml .decode ('utf-8' )
26
+ xml = xml .replace ('</w:hyperlink>' , '' )
27
+ xml = re .sub ('<w:hyperlink[^>]*>' , '' , xml )
28
+ if (sys .version_info > (3 , 0 )):
29
+ xml = xml .encode ('utf-8' )
30
+ return xml
31
+
32
+
21
33
def parse_xml (xml ):
22
34
"""
23
35
Return root lxml element obtained by parsing XML character string in
24
36
*xml*, which can be either a Python 2.x string or unicode. The custom
25
37
parser is used, so custom element classes are produced for elements in
26
38
*xml* that have them.
27
39
"""
28
- root_element = etree .fromstring (xml , oxml_parser )
40
+ root_element = etree .fromstring (remove_hyperlink_tags ( xml ) , oxml_parser )
29
41
return root_element
30
42
31
43
You can’t perform that action at this time.
0 commit comments