Skip to content

Commit

Permalink
Update posts.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Feb 2, 2025
1 parent 99340e3 commit ffc1471
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions api/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ def upsert_single_post(post):
# upsert InvenioRDM record
record = (
supabase.table("posts")
.select(postsWithContentSelect)
.select(postsWithCitationsSelect)
.eq("guid", post.get("guid", None))
.maybe_single()
.execute()
Expand Down Expand Up @@ -2212,16 +2212,20 @@ def format_citation(citation):

unstructured = citation.get("unstructured", None)

if citation.get("id", None):
if citation.get("citation", None):
# remove duplicate ID from unstructured reference
unstructured = unstructured.replace(citation.get("id"), "")
unstructured = unstructured.replace(citation.get("citation"), "")

# remove optional trailing whitespace
unstructured = unstructured.rstrip()

# remove HTML tags such as <i> and <sup> from unstructured citation
tags = nh3.ALLOWED_TAGS - {"b", "i", "sup", "sub"}
unstructured = nh3.clean(unstructured, tags=tags)

return compact(
{
"identifier": citation.get("id", None),
"identifier": citation.get("citation", None),
"scheme": "doi",
"reference": unstructured,
}
Expand Down

0 comments on commit ffc1471

Please sign in to comment.