From 679d1275353543aa21453000059c8d78bd1c84d5 Mon Sep 17 00:00:00 2001 From: Emiliano Heyns Date: Sat, 16 Mar 2024 12:32:49 +0100 Subject: [PATCH] fixes #2816 --- test/features/export.feature | 1 + ...issing Extra fields eg issued #2816.bibtex | 76 +++++++++++++++++++ ... missing Extra fields eg issued #2816.json | 47 ++++++++++++ translators/bibtex/bibtex.ts | 3 +- translators/bibtex/entry.ts | 1 + 5 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/export/Better BibTeX export from Zotero missing Extra fields eg issued #2816.bibtex create mode 100644 test/fixtures/export/Better BibTeX export from Zotero missing Extra fields eg issued #2816.json diff --git a/test/features/export.feature b/test/features/export.feature index 3da2a591d9..370cea2880 100644 --- a/test/features/export.feature +++ b/test/features/export.feature @@ -206,6 +206,7 @@ Feature: Export Examples: | file | references | + | Better BibTeX export from Zotero missing Extra fields eg issued #2816 | 1 | | formula grouping | 1 | | formula grouping-upgrade | 1 | | BBT does not escape # in first argument of href in note #2617 | 2 | diff --git a/test/fixtures/export/Better BibTeX export from Zotero missing Extra fields eg issued #2816.bibtex b/test/fixtures/export/Better BibTeX export from Zotero missing Extra fields eg issued #2816.bibtex new file mode 100644 index 0000000000..f0f45749c2 --- /dev/null +++ b/test/fixtures/export/Better BibTeX export from Zotero missing Extra fields eg issued #2816.bibtex @@ -0,0 +1,76 @@ +@book{rafn1829, + title = {{Fornaldar s{\"o}gur Nordrlanda eptir g{\"o}mlum handritum}}, + editor = {Rafn, Carl Christian}, + year = {1829/1830}, + publisher = {Popp}, + address = {Copenhagen}, + langid = {danish}, + note = {vol I: +\par +1. Hr{\'o}lfs saga kraka +\par +2. Bjarkam{\'a}l +\par +3. V{\"o}lsunga saga +\par +4. Ragnars saga +\par +5. Kr{\'a}kum{\'a}l +\par +6. Norna Gests {\th}{\'a}ttr +\par +7. Ragnarsona {\th}{\'a}ttr +\par +8. S{\"o}gubrot +\par +9. S{\"o}rla {\th}{\'a}ttr +\par +10. Hervarar saga +\par +vol II: \\ +1. Fr{\'a} Fornjoti ok hans {\ae}ttm{\"o}nnum, +\par +2. H{\'a}lfs saga ok H{\'a}lfsreka (23-60), +\par +3. Fri{\dh}{\th}jofs saga ens fr{\ae}kna (61-100), +\par +4. Af Upplendinga konungum (101-106), +\par +5. Ketils saga h{\ae}ngs (107-139), +\par +6. Gr{\'i}ms saga lo{\dh}inkinna (141-157), +\par +7, {\"O}rvar-Odds saga (159-322), +\par +8. Ans saga Bogsveigis (323-362), +\par +9. Hr{\'o}mundar saga (363-380), +\par +10. {\TH}orsteins saga vikingssonar (381-459), +\par +11. Asmundar saga kappabana (461-487) +\par +vol. III +\par +1. Gautreks saga [sem sumir kalla Gjafa-Refs s{\"o}gu] +\par +2. Hr{\'o}lfs saga Gautrekssonar +\par +3. B{\'o}sa saga +\par +4. S{\"o}gu-Hr{\'o}lfs saga +\par +5. Egils saga einhenda +\par +6. S{\"o}rla saga sterka +\par +7. Hj{\'a}lers saga og Olvers +\par +8. H{\'a}lfdanae saga Eysteinnsonar +\par +9. H{\'a}lfdanar saga Br{\"o}nuf{\'o}stra +\par +10. Sturlaugs saga startama +\par +11. Illuga saga} +} diff --git a/test/fixtures/export/Better BibTeX export from Zotero missing Extra fields eg issued #2816.json b/test/fixtures/export/Better BibTeX export from Zotero missing Extra fields eg issued #2816.json new file mode 100644 index 0000000000..c074396371 --- /dev/null +++ b/test/fixtures/export/Better BibTeX export from Zotero missing Extra fields eg issued #2816.json @@ -0,0 +1,47 @@ +{ + "config": { + "id": "36a3b0b5-bad0-4a04-b79b-441c7cef77db", + "label": "BetterBibTeX JSON", + "options": { + "Items": true, + "Preferences": true, + "exportNotes": true, + "worker": true + }, + "preferences": { + "DOIandURL": "doi", + "autoAbbrevStyle": "http://www.zotero.org/styles/cell", + "autoExportDelay": 2, + "citekeyFormat": "auth.lower+year" + } + }, + "items": [ + { + "citationKey": "rafn1829", + "creators": [ + { + "creatorType": "editor", + "firstName": "Carl Christian", + "lastName": "Rafn" + } + ], + "date": "1829\u20131830", + "extra": [ + "bibtex: rafn1829", + "Issued: 1829/1830" + ], + "itemID": 1, + "itemType": "book", + "language": "da", + "notes": [ + "

vol I:

\n

1. Hr\u00f3lfs saga kraka

\n

2. Bjarkam\u00e1l

\n

3. V\u00f6lsunga saga

\n

4. Ragnars saga

\n

5. Kr\u00e1kum\u00e1l

\n

6. Norna Gests \u00fe\u00e1ttr

\n

7. Ragnarsona \u00fe\u00e1ttr

\n

8. S\u00f6gubrot

\n

9. S\u00f6rla \u00fe\u00e1ttr

\n

10. Hervarar saga

", + "

vol II:
1. Fr\u00e1 Fornjoti ok hans \u00e6ttm\u00f6nnum,

\n

2. H\u00e1lfs saga ok H\u00e1lfsreka (23-60),

\n

3. Fri\u00f0\u00fejofs saga ens fr\u00e6kna (61-100),

\n

4. Af Upplendinga konungum (101-106),

\n

5. Ketils saga h\u00e6ngs (107-139),

\n

6. Gr\u00edms saga lo\u00f0inkinna (141-157),

\n

7, \u00d6rvar-Odds saga (159-322),

\n

8. Ans saga Bogsveigis (323-362),

\n

9. Hr\u00f3mundar saga (363-380),

\n

10. \u00deorsteins saga vikingssonar (381-459),

\n

11. Asmundar saga kappabana (461-487)

", + "

vol. III

\n

1. Gautreks saga [sem sumir kalla Gjafa-Refs s\u00f6gu]

\n

2. Hr\u00f3lfs saga Gautrekssonar

\n

3. B\u00f3sa saga

\n

4. S\u00f6gu-Hr\u00f3lfs saga

\n

5. Egils saga einhenda

\n

6. S\u00f6rla saga sterka

\n

7. Hj\u00e1lers saga og Olvers

\n

8. H\u00e1lfdanae saga Eysteinnsonar

\n

9. H\u00e1lfdanar saga Br\u00f6nuf\u00f3stra

\n

10. Sturlaugs saga startama

\n

11. Illuga saga

" + ], + "numberOfVolumes": "3", + "place": "Copenhagen", + "publisher": "Popp", + "title": "Fornaldar s\u00f6gur Nordrlanda eptir g\u00f6mlum handritum" + } + ] +} \ No newline at end of file diff --git a/translators/bibtex/bibtex.ts b/translators/bibtex/bibtex.ts index 97ab6a2c8d..356070ba05 100644 --- a/translators/bibtex/bibtex.ts +++ b/translators/bibtex/bibtex.ts @@ -387,8 +387,7 @@ export function generateBibTeX(translation: Translation): void { break case 'interval': - if (ref.date.from.month) ref.add({ name: 'month', value: months[ref.date.from.month - 1], bare: true }) - ref.add({ name: 'year', value: `${ref.date.from.year}` }) + ref.add({ name: 'year', value: item.date }) break case 'date': diff --git a/translators/bibtex/entry.ts b/translators/bibtex/entry.ts index e5fc40ac68..2258ba612a 100644 --- a/translators/bibtex/entry.ts +++ b/translators/bibtex/entry.ts @@ -220,6 +220,7 @@ export class Entry { } this.extraFields = JSON.parse(JSON.stringify(item.extraFields)) + log.debug('extra-fields:', this.extraFields) // should be const entrytype: string | { type: string, subtype?: string } // https://github.com/Microsoft/TypeScript/issues/10422