From 6b43779dc28dbb78a7133360c1601724b55cd7f9 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sat, 16 May 2020 23:12:03 +0100 Subject: [PATCH 1/2] Added test with `year = 2020` at end of entry This test fails, because the parsed year value (using `key()`) fails the correctness check, because it has a newline in it. Signed-off-by: Stefan Marr --- test/proceedings.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/proceedings.js diff --git a/test/proceedings.js b/test/proceedings.js new file mode 100644 index 0000000..098f553 --- /dev/null +++ b/test/proceedings.js @@ -0,0 +1,28 @@ +import test from 'ava'; + +const bibtexParse = require('../bibtexParse'); + +const input = `@proceedings{Last:2020:P20I3, + doi = {10.22152/programming-journal.org/2020/4/issue3}, + editor = {Last, First}, + month = {February}, + publisher = {AOSA Inc.}, + title = {The Art, Science, and Engineering of Programming}, + url = {https://programming-journal.org/2020/4/issue3/}, + volume = 4, + year = 2020 +}` + +const output = [ { citationKey: 'Last:2020:P20I3', + entryType: 'proceedings', + entryTags: + { title: 'The Art, Science, and Engineering of Programming', + year: '2020', + month: 'February', + editor: 'Last, First', + publisher: 'AOSA Inc.', + volume: '4', + doi: '10.22152/programming-journal.org/2020/4/issue3', + url: 'https://programming-journal.org/2020/4/issue3/' } } ] + +test('proceedings should parse', t => t.deepEqual(output, bibtexParse.toJSON(input))); From 5181b49f4a0f19a02dae3e0514ba50cb7dafdd9a Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sat, 16 May 2020 23:12:44 +0100 Subject: [PATCH 2/2] Use trim() to make value compatible with regex Signed-off-by: Stefan Marr --- bibtexParse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bibtexParse.js b/bibtexParse.js index 4bac1ac..796962b 100644 --- a/bibtexParse.js +++ b/bibtexParse.js @@ -172,7 +172,7 @@ } else if (this.tryMatch('"')) { return this.value_quotes(); } else { - var k = this.key(); + var k = this.key().trim(); if (k.match("^[0-9]+$")) return k; else if (this.months.indexOf(k.toLowerCase()) >= 0)