parent
f2209974b2
commit
745069c070
2 changed files with 15 additions and 5 deletions
|
@ -1983,11 +1983,9 @@ Zotero.Items = function() {
|
||||||
'</span>',
|
'</span>',
|
||||||
// Any punctuation at the beginning of the string
|
// Any punctuation at the beginning of the string
|
||||||
'^\\p{P}+',
|
'^\\p{P}+',
|
||||||
// Initial, opening, closing, final, other punctuation:
|
// Initial, opening, closing, final, and "other" punctuation that isn't
|
||||||
// pretty much anything that isn't a connector/dash.
|
// followed by a digit. Doesn't match connectors or dashes.
|
||||||
// Positively matching each of these classes compiles to a cleaner
|
'[\\p{Pi}\\p{Ps}\\p{Pe}\\p{Pf}\\p{Po}](?!\\d)'
|
||||||
// native RegExp than XRegExp('[^\\P{P}\\p{Pd}]')
|
|
||||||
'[\\p{Pi}\\p{Ps}\\p{Pe}\\p{Pf}\\p{Po}]'
|
|
||||||
].map(re => Zotero.Utilities.XRegExp(re, 'g'));
|
].map(re => Zotero.Utilities.XRegExp(re, 'g'));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1163,5 +1163,17 @@ describe("Zotero.Items", function () {
|
||||||
assert.equal(Zotero.Items.getSortTitle(input), expected);
|
assert.equal(Zotero.Items.getSortTitle(input), expected);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not strip any punctuation before a digit", function () {
|
||||||
|
let tests = [
|
||||||
|
['1.5', '1.5'],
|
||||||
|
['abc .5', 'abc .5'],
|
||||||
|
['abc 5.', 'abc 5']
|
||||||
|
];
|
||||||
|
|
||||||
|
for (let [input, expected] of tests) {
|
||||||
|
assert.equal(Zotero.Items.getSortTitle(input), expected);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue