Automatically capitalize subtitle for APA styles

Applied to all styles with ids matching 'apa($|-)'

Currently limited to colons, but Juris-M/citeproc-js#74 may extend this
to other punctuation

Closes #1681
This commit is contained in:
Dan Stillman 2019-04-21 17:03:16 -04:00
parent 7496faa8cf
commit a0be2da42c
2 changed files with 16 additions and 4 deletions

View file

@ -584,13 +584,20 @@ Zotero.Cite.getAbbreviation = new function() {
/** /**
* citeproc-js system object * citeproc-js system object
*
* @class * @class
* @param {Object} options
* @param {Boolean} [options.automaticJournalAbbreviations]
* @param {Boolean} [options.uppercaseSubtitles]
*/ */
Zotero.Cite.System = function(automaticJournalAbbreviations) { Zotero.Cite.System = function ({ automaticJournalAbbreviations, uppercaseSubtitles }) {
if(automaticJournalAbbreviations) { if (automaticJournalAbbreviations) {
this.getAbbreviation = Zotero.Cite.getAbbreviation; this.getAbbreviation = Zotero.Cite.getAbbreviation;
} }
} if (uppercaseSubtitles) {
this.uppercase_subtitles = true; // eslint-disable-line camelcase
}
};
Zotero.Cite.System.prototype = { Zotero.Cite.System.prototype = {
/** /**

View file

@ -648,6 +648,8 @@ Zotero.Style = function (style, path) {
Zotero.Styles.ns).replace(/(.+)T([^\+]+)\+?.*/, "$1 $2"); Zotero.Styles.ns).replace(/(.+)T([^\+]+)\+?.*/, "$1 $2");
this.locale = Zotero.Utilities.xpathText(doc, '/csl:style/@default-locale', this.locale = Zotero.Utilities.xpathText(doc, '/csl:style/@default-locale',
Zotero.Styles.ns) || null; Zotero.Styles.ns) || null;
var shortID = this.styleID.match(/\/?([^/]+)$/)[1];
this._isAPA = /^apa($|-)/.test(shortID);
this._class = doc.documentElement.getAttribute("class"); this._class = doc.documentElement.getAttribute("class");
this._usesAbbreviation = !!Zotero.Utilities.xpath(doc, this._usesAbbreviation = !!Zotero.Utilities.xpath(doc,
'//csl:text[(@variable="container-title" and @form="short") or (@variable="container-title-short")][1]', '//csl:text[(@variable="container-title" and @form="short") or (@variable="container-title-short")][1]',
@ -745,7 +747,10 @@ Zotero.Style.prototype.getCiteProc = function(locale, automaticJournalAbbreviati
try { try {
var citeproc = new Zotero.CiteProc.CSL.Engine( var citeproc = new Zotero.CiteProc.CSL.Engine(
new Zotero.Cite.System(automaticJournalAbbreviations), new Zotero.Cite.System({
automaticJournalAbbreviations,
uppercaseSubtitles: this._isAPA
}),
xml, xml,
locale, locale,
overrideLocale overrideLocale