Apply subtitle capitalization to dependent styles based on parent

If a style specifies a style like APA that wants uppercase subtitles,
the dependent style should have them too.

https://forums.zotero.org/discussion/comment/364864/#Comment_364864
This commit is contained in:
Dan Stillman 2020-09-22 14:55:08 -04:00
parent c5f01bc2f3
commit 693cd926d5

View file

@ -649,12 +649,6 @@ Zotero.Style = function (style, path) {
this.locale = Zotero.Utilities.xpathText(doc, '/csl:style/@default-locale',
Zotero.Styles.ns) || null;
// APA and some similar styles capitalize the first word of subtitles
this._uppercaseSubtitles = false;
var uppercaseSubtitlesRE = /^apa($|-)|^(academy-of-management|freshwater-science)/;
var shortIDMatches = this.styleID.match(/\/?([^/]+)$/);
this._uppercaseSubtitles = !!shortIDMatches && uppercaseSubtitlesRE.test(shortIDMatches[1]);
this._class = doc.documentElement.getAttribute("class");
this._usesAbbreviation = !!Zotero.Utilities.xpath(doc,
'//csl:text[(@variable="container-title" and @form="short") or (@variable="container-title-short")][1]',
@ -698,6 +692,11 @@ Zotero.Style.prototype.getCiteProc = function(locale, automaticJournalAbbreviati
}
}
// APA and some similar styles capitalize the first word of subtitles
var uppercaseSubtitlesRE = /^apa($|-)|^academy-of-management($|-)|^(freshwater-science)/;
var shortIDMatches = this.styleID.match(/\/?([^/]+)$/);
var uppercaseSubtitles = !!shortIDMatches && uppercaseSubtitlesRE.test(shortIDMatches[1]);
// determine version of parent style
var overrideLocale = false; // to force dependent style locale
if(this.source) {
@ -717,7 +716,14 @@ Zotero.Style.prototype.getCiteProc = function(locale, automaticJournalAbbreviati
overrideLocale = true;
locale = this.locale;
}
} else {
// Turn on uppercase subtitles if parent style matches
if (!uppercaseSubtitles) {
let shortIDMatches = parentStyle.styleID.match(/\/?([^/]+)$/);
uppercaseSubtitles = !!shortIDMatches && uppercaseSubtitlesRE.test(shortIDMatches[1]);
}
}
else {
var version = this._version;
}
@ -754,7 +760,7 @@ Zotero.Style.prototype.getCiteProc = function(locale, automaticJournalAbbreviati
var citeproc = new Zotero.CiteProc.CSL.Engine(
new Zotero.Cite.System({
automaticJournalAbbreviations,
uppercaseSubtitles: this._uppercaseSubtitles
uppercaseSubtitles
}),
xml,
locale,