Be more lenient about Extra field values than citeproc-js
Allow fields like "Original Date: 2018" and convert them to "original-date: 2018" when sending to citeproc-js. For reference: http://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html#cheater-syntax-for-odd-fields
This commit is contained in:
parent
e1e5178869
commit
1f320e1f5d
4 changed files with 130 additions and 0 deletions
25
test/tests/citeTest.js
Normal file
25
test/tests/citeTest.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
describe("Zotero.Cite", function () {
|
||||
describe("#extraToCSL()", function () {
|
||||
it("should convert Extra field values to the more restrictive citeproc-js cheater syntax", function () {
|
||||
var str1 = 'Original Date: 2017\n' // uppercase/spaces converted to lowercase/hyphens
|
||||
+ 'Archive-Place: New York\n' // allow hyphen even with title case
|
||||
+ 'Container title: Title\n' // mixed case
|
||||
+ 'DOI: 10.0/abc\n' // certain fields are uppercase
|
||||
+ 'Archive Location: Foo\n' // requires an underscore
|
||||
+ 'Original Publisher Place: London, UK\n' // extra space OK
|
||||
+ '\n\n'
|
||||
+ "Ignore other strings: they're not fields\n"
|
||||
+ 'This is just some text.'
|
||||
var str2 = 'original-date: 2017\n'
|
||||
+ 'archive-place: New York\n'
|
||||
+ 'container-title: Title\n'
|
||||
+ 'DOI: 10.0/abc\n'
|
||||
+ 'archive_location: Foo\n'
|
||||
+ 'original-publisher-place: London, UK\n'
|
||||
+ '\n\n'
|
||||
+ "Ignore other strings: they're not fields\n"
|
||||
+ 'This is just some text.';
|
||||
assert.equal(Zotero.Cite.extraToCSL(str1), str2);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue