summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/hacks.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-04-09 12:14:56 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-04-09 12:14:56 -0700
commit70f652deb27d5e7b11ed54e9e418331ebb1bbae7 (patch)
tree4cf1a3c01b23d1b47ec8a2b3d35fbccbd6ff7529 /python/fatcat_web/hacks.py
parent3c5bd4d21f4744ae444819adaffa20e3b52ea61c (diff)
downloadfatcat-70f652deb27d5e7b11ed54e9e418331ebb1bbae7.tar.gz
fatcat-70f652deb27d5e7b11ed54e9e418331ebb1bbae7.zip
temporary hack to remove ext-link XML in refs
Diffstat (limited to 'python/fatcat_web/hacks.py')
-rw-r--r--python/fatcat_web/hacks.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/fatcat_web/hacks.py b/python/fatcat_web/hacks.py
new file mode 100644
index 00000000..51b97142
--- /dev/null
+++ b/python/fatcat_web/hacks.py
@@ -0,0 +1,15 @@
+
+import re
+
+STRIP_EXTLINK_XML_RE = re.compile(r"<ext-link.*xlink:type=\"simple\">")
+
+def strip_extlink_xml(unstr):
+ unstr = unstr.replace("</ext-link>", "")
+ unstr = STRIP_EXTLINK_XML_RE.sub("", unstr)
+ return unstr
+
+def test_strip_extlink_xml():
+ assert strip_extlink_xml("asdf") == "asdf"
+ assert strip_extlink_xml("""LOCKSS (2014) Available: <ext-link xmlns:xlink="http://www.w3.org/1999/xlink" ext-link-type="uri" xlink:href="http://lockss.org/" xlink:type="simple">http://lockss.org/</ext-link>. Accessed: 2014 November 1.""") == \
+ """LOCKSS (2014) Available: http://lockss.org/. Accessed: 2014 November 1."""
+