Update citeproc-js to 1.1.169

This commit is contained in:
Dan Stillman 2017-05-23 17:39:10 -04:00
parent 79ed9e8448
commit 319edae7f2

View file

@ -23,7 +23,7 @@
* <http://www.gnu.org/licenses/> respectively. * <http://www.gnu.org/licenses/> respectively.
*/ */
var CSL = { var CSL = {
PROCESSOR_VERSION: "1.1.167", PROCESSOR_VERSION: "1.1.169",
CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_TOP: 1,
CONDITION_LEVEL_BOTTOM: 2, CONDITION_LEVEL_BOTTOM: 2,
PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/,
@ -14455,7 +14455,8 @@ CSL.Util.FlipFlopper = function(state) {
outer: "true", outer: "true",
flipflop: { flipflop: {
"true": "inner", "true": "inner",
"inner": "true" "inner": "true",
"false": "true"
} }
}, },
" \'": { " \'": {
@ -14466,7 +14467,8 @@ CSL.Util.FlipFlopper = function(state) {
outer: "inner", outer: "inner",
flipflop: { flipflop: {
"true": "inner", "true": "inner",
"inner": "true" "inner": "true",
"false": "true"
} }
} }
} }
@ -14615,19 +14617,32 @@ CSL.Util.FlipFlopper = function(state) {
} }
} }
function _doppelString(str) { function _doppelString(str) {
var forcedSpaces = [];
str = str.replace(/(<span)\s+(style=\"font-variant:)\s*(small-caps);?\"[^>]*(>)/g, "$1 $2$3;\"$4"); str = str.replace(/(<span)\s+(style=\"font-variant:)\s*(small-caps);?\"[^>]*(>)/g, "$1 $2$3;\"$4");
str = str.replace(/(<span)\s+(class=\"no(?:case|decor)\")[^>]*(>)/g, "$1 $2$3"); str = str.replace(/(<span)\s+(class=\"no(?:case|decor)\")[^>]*(>)/g, "$1 $2$3");
var match = str.match(_tagRex.matchAll); var match = str.match(_tagRex.matchAll);
if (!match) { if (!match) {
return { return {
tags: [], tags: [],
strings: [str] strings: [str],
forcedSpaces: []
}; };
} }
var split = str.split(_tagRex.splitAll); var split = str.split(_tagRex.splitAll);
for (var i=0,ilen=match.length-1;i<ilen;i++) {
if (_nestingData[match[i]]) {
if (split[i+1] === "" && ["\"", "'"].indexOf(match[i+1]) > -1) {
match[i+1] = " " + match[i+1]
forcedSpaces.push(true);
} else {
forcedSpaces.push(false);
}
}
}
return { return {
tags: match, tags: match,
strings: split strings: split,
forcedSpaces: forcedSpaces
} }
} }
function _undoppelString(obj) { function _undoppelString(obj) {
@ -14701,7 +14716,7 @@ CSL.Util.FlipFlopper = function(state) {
function Stack (blob) { function Stack (blob) {
this.stack = [blob]; this.stack = [blob];
this.latest = blob; this.latest = blob;
this.addStyling = function(str, decor) { this.addStyling = function(str, decor, forcedSpace) {
if (firstString) { if (firstString) {
if (str.slice(0, 1) === " ") { if (str.slice(0, 1) === " ") {
str = str.slice(1); str = str.slice(1);
@ -14821,7 +14836,11 @@ CSL.Util.FlipFlopper = function(state) {
doppel.strings[i+1] = "\u2019" + doppel.strings[i+1]; doppel.strings[i+1] = "\u2019" + doppel.strings[i+1];
doppel.tags[i] = ""; doppel.tags[i] = "";
} else { } else {
doppel.strings[tagInfo.fixtag+1] = doppel.tags[tagInfo.fixtag] + doppel.strings[tagInfo.fixtag+1]; var failedTag = doppel.tags[tagInfo.fixtag];
if (doppel.forcedSpaces[tagInfo.fixtag-1]) {
failedTag = failedTag.slice(1);
}
doppel.strings[tagInfo.fixtag+1] = failedTag + doppel.strings[tagInfo.fixtag+1];
doppel.tags[tagInfo.fixtag] = ""; doppel.tags[tagInfo.fixtag] = "";
} }
if (_nestingState.length > 0) { if (_nestingState.length > 0) {
@ -14851,11 +14870,10 @@ CSL.Util.FlipFlopper = function(state) {
var tag = doppel.tags[tagPos]; var tag = doppel.tags[tagPos];
if (tag === " \'" || tag === "\'") { if (tag === " \'" || tag === "\'") {
doppel.strings[tagPos+1] = " \u2019" + doppel.strings[tagPos+1]; doppel.strings[tagPos+1] = " \u2019" + doppel.strings[tagPos+1];
doppel.tags[tagPos] = "";
} else { } else {
doppel.strings[tagPos+1] = doppel.tags[tagPos] + doppel.strings[tagPos+1]; doppel.strings[tagPos+1] = doppel.tags[tagPos] + doppel.strings[tagPos+1];
doppel.tags[tagPos] = "";
} }
doppel.tags[tagPos] = "";
_nestingState.pop(); _nestingState.pop();
} }
for (var i=doppel.tags.length-1;i>-1;i--) { for (var i=doppel.tags.length-1;i>-1;i--) {
@ -14867,12 +14885,15 @@ CSL.Util.FlipFlopper = function(state) {
} }
for (var i=0,ilen=doppel.tags.length;i<ilen;i++) { for (var i=0,ilen=doppel.tags.length;i<ilen;i++) {
var tag = doppel.tags[i]; var tag = doppel.tags[i];
if ([" \"", " \'", "(\""].indexOf(tag) > -1) { var forcedSpace = doppel.forcedSpaces[i-1];
if ([" \"", " \'", "(\"", "(\'"].indexOf(tag) > -1) {
if (!quoteFormSeen) { if (!quoteFormSeen) {
_setOuterQuoteForm(tag); _setOuterQuoteForm(tag);
quoteFormSeen = true; quoteFormSeen = true;
} }
doppel.strings[i] += tag.slice(0, 1); if (!forcedSpace) {
doppel.strings[i] += tag.slice(0, 1);
}
} }
} }
_undoppelToQueue(blob, doppel, leadingSpace); _undoppelToQueue(blob, doppel, leadingSpace);