From e9ea9ae171282a828117821d525d342a32e39bcd Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 4 Apr 2020 03:53:08 -0400 Subject: [PATCH] Leave Event Place and Publisher Place in Extra on import These CSL variables are both currently mapped to the Zotero Place field, but that's imprecise and will change: https://github.com/citation-style-language/zotero-bits/issues/6 So for now, don't convert these to a Place line or make them eligible for migration to a real field (once we turn that on). https://groups.google.com/d/msgid/zotero-dev/806a22e3-3d6a-4d86-8747-10c787291a93%40googlegroups.com --- .../zotero/xpcom/utilities_internal.js | 6 +++++ test/tests/utilities_internalTest.js | 24 ++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index af120c7d60..ba7bfe1004 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -1043,6 +1043,12 @@ Zotero.Utilities.Internal = { return true; } + // Skip for now, since the mappings to Place will be changed + // https://github.com/citation-style-language/zotero-bits/issues/6 + if (key == 'event-place' || key == 'publisher-place') { + return true; + } + // Fields let possibleFields = fieldNames.get(key); // No valid fields diff --git a/test/tests/utilities_internalTest.js b/test/tests/utilities_internalTest.js index 660fe1a099..0431dd1b6b 100644 --- a/test/tests/utilities_internalTest.js +++ b/test/tests/utilities_internalTest.js @@ -175,24 +175,24 @@ describe("Zotero.Utilities.Internal", function () { }); it("should extract a field with other fields, text, and whitespace", function () { - var place = 'New York'; + var date = '2020-04-01'; var doi = '10.1234/abcdef'; - var str = `Line 1\nPublisher Place: ${place}\nFoo: Bar\nDOI: ${doi}\n\nLine 2`; + var str = `Line 1\nDate: ${date}\nFoo: Bar\nDOI: ${doi}\n\nLine 2`; var { fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str); assert.equal(fields.size, 2); + assert.equal(fields.get('date'), date); assert.equal(fields.get('DOI'), doi); - assert.equal(fields.get('place'), place); assert.equal(extra, 'Line 1\nFoo: Bar\n\nLine 2'); }); it("should extract the first instance of a field", function () { - var place1 = 'New York'; - var place2 = 'London'; - var str = `Publisher Place: ${place1}\nPublisher Place: ${place2}`; + var date1 = '2020-04-01'; + var date2 = '2020-04-02'; + var str = `Date: ${date1}\nDate: ${date2}`; var { fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str); assert.equal(fields.size, 1); - assert.equal(fields.get('place'), place1); - assert.equal(extra, "Publisher Place: " + place2); + assert.equal(fields.get('date'), date1); + assert.equal(extra, "Date: " + date2); }); it("shouldn't extract a field from a line that begins with a whitespace", function () { @@ -265,6 +265,14 @@ describe("Zotero.Utilities.Internal", function () { assert.equal(fields.get('date'), 2014); assert.strictEqual(extra, ''); }); + + it("should ignore both Event Place and Publisher Place (temporary)", function () { + var str = "Event Place: Foo\nPublisher Place: Bar"; + var { fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str); + Zotero.debug([...fields.entries()]); + assert.equal(fields.size, 0); + assert.equal(extra, "Event Place: Foo\nPublisher Place: Bar"); + }); }); describe("#combineExtraFields", function () {