From c39e3e69b79316fb39c4a98e27b8fbe6627e9a20 Mon Sep 17 00:00:00 2001 From: Emiliano Heyns Date: Fri, 1 Nov 2024 16:25:00 +0100 Subject: [PATCH] fixes #3040 --- test/features/export.feature | 1 + ...nted out in biblatex output #3040.biblatex | 14 +++++ ...ommented out in biblatex output #3040.json | 53 +++++++++++++++++++ translators/bibtex/entry.ts | 5 +- 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/export/Duplicate note is not correctly commented out in biblatex output #3040.biblatex create mode 100644 test/fixtures/export/Duplicate note is not correctly commented out in biblatex output #3040.json diff --git a/test/features/export.feature b/test/features/export.feature index 74aa1ed78..94bc933f5 100644 --- a/test/features/export.feature +++ b/test/features/export.feature @@ -13,6 +13,7 @@ Feature: Export Examples: | file | references | + | Duplicate note is not correctly commented out in biblatex output #3040 | 1 | | citekey not skip one-letter word #3021 | 1 | | charmapcsv mapping not working anymore #3020 | 1 | | Use nonacademic entrysubtype in place of newspapermagazine for biblatex-apa #2987 | 1 | diff --git a/test/fixtures/export/Duplicate note is not correctly commented out in biblatex output #3040.biblatex b/test/fixtures/export/Duplicate note is not correctly commented out in biblatex output #3040.biblatex new file mode 100644 index 000000000..aef64960d --- /dev/null +++ b/test/fixtures/export/Duplicate note is not correctly commented out in biblatex output #3040.biblatex @@ -0,0 +1,14 @@ +@book{McDougallTJ.Barker-delete-me, + title = {Getting started with {{TEOS-10}} and the {{Gibbs Seawater}} ({{GSW}}) {{Oceanographic Toolbox}}}, + author = {McDougall, Trevor J and Barker, Paul M}, + date = {2011}, + publisher = {Trevor J McDougall}, + location = {Battery Point, Tasmania, Australia}, + url = {https://www.teos-10.org/pubs/Getting_Started.pdf}, + isbn = {978-0-646-55621-5}, + language = {English}, + annotation = {OCLC: 724024071}, + note = {OCLC: 724024071} +} +% == BibLateX quality report for McDougallTJ.Barker-delete-me: +% ? unused Library catalog ("Open WorldCat") diff --git a/test/fixtures/export/Duplicate note is not correctly commented out in biblatex output #3040.json b/test/fixtures/export/Duplicate note is not correctly commented out in biblatex output #3040.json new file mode 100644 index 000000000..8a79be00c --- /dev/null +++ b/test/fixtures/export/Duplicate note is not correctly commented out in biblatex output #3040.json @@ -0,0 +1,53 @@ +{ + "config": { + "id": "36a3b0b5-bad0-4a04-b79b-441c7cef77db", + "label": "BetterBibTeX JSON", + "preferences": { + "asciiBibLaTeX": true, + "autoAbbrev": true, + "autoExportDelay": 8, + "baseAttachmentPath": "/Users/furue/Dropbox/doc/papers", + "bibtexURL": "url", + "citekeyFormat": "authEtal2(initials=true).capitalize+\":\"+year", + "exportTitleCase": false, + "extraMergeCSL": true, + "language": "language", + "postscript": "if (Translator.BetterTeX) {\n if (item.extra) reference.add({ name: 'note', value: item.extra.replace(/(https?:\\/\\/[^ ]+)/, \"\") })\n}", + "qualityReport": true, + "skipFields": "abstract,file,issn", + "strings": "@string{AO\t= \"Atmos.\\ Ocean\"}\n@string{ARFM\t= \"Annu.\\ Rev.\\ Fluid Mech.\"}\n@string{BAMS\t= \"Bull.\\ Amer.\\ Meteor.\\ Soc.\"}\n@string{BullMarSci = \"Bulletin of Marine Science\"}\n@string{CD\t= \"Climate Dynamics\"}\n@string{CSR\t= \"Cont.~Shelf Res.\"}\n@string{DAO\t= \"Dyn.\\ Atmos.\\ Oceans.\"}\n@string{DSR\t= \"Deep Sea Res.\"}\n@string{DSR1\t= \"Deep Sea Res.~I\"}\n@string{DSR2\t= \"Deep Sea Res.~II\"}\n@string{DSRA\t= \"Deep Sea Res.\\ Part~A\"}\n@string{FMARS\t= \"Front.\\ Mar.\\ Sci.\"}\n@string{GAFD\t= \"Geophys.\\ Astrophys.\\ Fluid Dyn.\"}\n@string{GBC\t= \"Global Biogeochem.\\ Cycles\"}\n@string{GRL\t= \"Geophys.\\ Res.\\ Lett.\"}\n@string{JAOT\t= \"J.\\ Atmos.\\ Oceanic Technol.\"}\n@string{JAS\t= \"J.\\ Atmos.\\ Sci.\"}\n@string{JC\t= \"J.\\ Climate\"}\n@string{JCP\t= \"J.\\ Comput.\\ Phys.\"}\n@string{JFM\t= \"J.\\ Fluid Mech.\"}\n@string{JGR\t= \"J.\\ Geophys.\\ Res.\"}\n@string{JGRC\t= \"J.\\ Geophys.\\ Res.\\ Oceans\"}\n@string{JMR\t= \"J.\\ Mar.\\ Res.\"}\n@string{JMSJ\t= \"J.\\ Meteorol.\\ Soc.\\ Japan\"}\n@string{JPlanktonRes = \"Journal of Plankton Research\"}\n@string{JPO\t= \"J.\\ Phys.\\ Oceanogr.\"}\n@string{JO\t= \"J.\\ Oceanogr.\"}\n@string{JOO = \"J. Oper.\\ Oceanogr.\"}\n@string{JOSJ\t= \"J.\\ Oceanogr.\\ Soc.\\ Japan\"}\n@string{MWR\t= \"Mon.\\ Wea.\\ Rev.\"}\n@string{OD\t= \"Ocean Dyn.\"}\n@string{OM\t= \"Ocean Modelling\"}\n@string{PF\t= \"Phys.\\ Fluids\"}\n@string{PhysRevLett = \"Phys.\\ Rev.\\ Lett.\"}\n@string{PO\t= \"Prog.\\ Oceanog.\"}\n@string{PRS\t= \"Proc.\\ Roy.\\ Soc., Ser.~A\"}\n@string{QJRMS\t= \"Quarterly J.\\ Roy.\\ Meteorol.\\ Soc.\"}\n@string{RG\t= \"Rev.\\ Geophys.\"}\n@string{RevGeophysSpacePhys = \"Rev.\\ Geophys.\\ Space Phys.\"}\n@string{SREP = \"Scientific Reports\"}", + "verbatimFields": "url,doi,file,eprint,verba,verbb,verbc,groups" + } + }, + "items": [ + { + "ISBN": "978-0-646-55621-5", + "citationKey": "McDougallTJ.Barker-delete-me", + "creators": [ + { + "creatorType": "author", + "firstName": "Trevor J", + "lastName": "McDougall" + }, + { + "creatorType": "author", + "firstName": "Paul M", + "lastName": "Barker" + } + ], + "date": "2011", + "extra": [ + "OCLC: 724024071", + "Citation Key: McDougallTJ.Barker-delete-me" + ], + "itemID": 1, + "itemType": "book", + "language": "English", + "libraryCatalog": "Open WorldCat", + "place": "Battery Point, Tasmania, Australia", + "publisher": "Trevor J McDougall", + "title": "Getting started with TEOS-10 and the Gibbs Seawater (GSW) Oceanographic Toolbox", + "url": "https://www.teos-10.org/pubs/Getting_Started.pdf" + } + ] +} diff --git a/translators/bibtex/entry.ts b/translators/bibtex/entry.ts index c2db9f86e..9bd36423d 100644 --- a/translators/bibtex/entry.ts +++ b/translators/bibtex/entry.ts @@ -516,7 +516,10 @@ export class Entry { v_old = v_old.toLowerCase() v_new = v_new.toLowerCase() } - if (v_old !== v_new) this.quality_report.push(`duplicate "${ field.name }" ("${ this.has[field.name].value }") ignored`) + if (v_old !== v_new) { + if (typeof v_old === 'string') v_old = v_old.replace(/[\r\n]+/g, ' ') + this.quality_report.push(`duplicate "${ field.name }" ("${ v_old }") ignored`) + } } delete this.has[field.name]