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
This commit is contained in:
parent
0e3d707576
commit
e9ea9ae171
2 changed files with 22 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Reference in a new issue