diff --git a/paperqa/types.py b/paperqa/types.py index 4f17ff88..41a907ea 100644 --- a/paperqa/types.py +++ b/paperqa/types.py @@ -145,13 +145,19 @@ def markdown(self) -> Tuple[str, str]: index = 1 for citation in iter_citations(self.answer): compound = "" - for c in citation.split(","): + for c in citation.split(",;"): c = c.strip("() ") if c == "Extra background information": continue if c in refs: compound += f"[^{refs[c]}]" continue + # check if it is a citation + try: + self.get_citation(c) + except ValueError: + # not a citation + continue refs[c] = index compound += f"[^{index}]" index += 1 diff --git a/paperqa/version.py b/paperqa/version.py index 62ee17b8..641cc783 100644 --- a/paperqa/version.py +++ b/paperqa/version.py @@ -1 +1 @@ -__version__ = "3.13.0" +__version__ = "3.13.1" diff --git a/tests/test_paperqa.py b/tests/test_paperqa.py index aa3185d1..2a06387b 100644 --- a/tests/test_paperqa.py +++ b/tests/test_paperqa.py @@ -49,7 +49,7 @@ def test_iter_citations(): "time. For instance, the effectiveness of COVID-19 vaccines against severe " "COVID-19 declined to 64% after 121 days, compared to around 90% initially " "(Chemaitelly2022WaningEO, Foo2019Bar). Despite this, vaccines still provide " - "significant protection against severe outcomes." + "significant protection against severe outcomes (Bar2000Foo pg 1-3; Far2000 pg 2-5)." ) ref = [ "(Dorabawila2022EffectivenessOT)", @@ -57,6 +57,7 @@ def test_iter_citations(): "(Thompson2021EffectivenessOC pg. 3-5, Goo2031Foo pg. 3-4)", "(Marfé2021EffectivenessOC)", "(Chemaitelly2022WaningEO, Foo2019Bar)", + "(Bar2000Foo pg 1-3; Far2000 pg 2-5)", ] assert list(iter_citations(text)) == ref @@ -130,13 +131,13 @@ def test_markdown(): answer = Answer( question="What was Fredic's greatest accomplishment?", answer="Frederick Bates's greatest accomplishment was his role in resolving land disputes " - "and his service as governor of Missouri (Wiki2023 chunk 1).", + "and his service as governor of Missouri (Wiki2023 chunk 1). It is said (in 2010) that foo.", contexts=[ Context( context="", text=Text( text="Frederick Bates's greatest accomplishment was his role in resolving land disputes " - "and his service as governor of Missouri (Wiki2023 chunk 1).", + "and his service as governor of Missouri.", name="Wiki2023 chunk 1", doc=Doc( name="Wiki2023",