summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-12-03 20:53:24 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-12-03 20:53:24 -0800
commit653432a70740a5920e8ac3ce02114d82dd5f8a05 (patch)
tree5a2a6d7c479227d7d2919c08cdb83f7d9ee155f8 /python
parent9eb548c9b325a8eeb800b4432ef78dfbfe02834a (diff)
downloadfatcat-653432a70740a5920e8ac3ce02114d82dd5f8a05.tar.gz
fatcat-653432a70740a5920e8ac3ce02114d82dd5f8a05.zip
improve previous commit (JATS abstract hack)
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_web/entity_helpers.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/python/fatcat_web/entity_helpers.py b/python/fatcat_web/entity_helpers.py
index ab45c6e2..af0fea83 100644
--- a/python/fatcat_web/entity_helpers.py
+++ b/python/fatcat_web/entity_helpers.py
@@ -78,10 +78,12 @@ def enrich_release_entity(entity):
entity.abstracts.reverse()
# hack to (partially) clean up common JATS abstract display case
if entity.abstracts[0].mimetype == 'application/xml+jats':
- entity.abstracts[0].content = entity.abstracts[0].content.replace('<jats>', '')
- entity.abstracts[0].content = entity.abstracts[0].content.replace('</jats>', '')
- entity.abstracts[0].content = entity.abstracts[0].content.replace('<jats:p>', '')
- entity.abstracts[0].content = entity.abstracts[0].content.replace('</jats:p>', '')
+ for tag in ('p', 'jats', 'jats:p'):
+ entity.abstracts[0].content = entity.abstracts[0].content.replace('<{}>'.format(tag), '')
+ entity.abstracts[0].content = entity.abstracts[0].content.replace('</{}>'.format(tag), '')
+ # ugh, double encoding happens
+ entity.abstracts[0].content = entity.abstracts[0].content.replace('&lt;/{}&gt;'.format(tag), '')
+ entity.abstracts[0].content = entity.abstracts[0].content.replace('&lt;{}&gt;'.format(tag), '')
return entity
def enrich_work_entity(entity):