mirror of
https://github.com/zotero/zotero.git
synced 2026-10-05 02:43:38 +00:00
Don't cache CSL.Engine for integration
This commit is contained in:
parent
128f2229e6
commit
5b82a38383
2 changed files with 21 additions and 4 deletions
|
|
@ -1927,7 +1927,10 @@ Zotero.Integration.Session.prototype.setData = async function (data, resetStyle)
|
|||
if (this.style && this.style.free) {
|
||||
this.style.free();
|
||||
}
|
||||
this.style = getStyle.getCiteProc(data.style.locale, this.outputFormat, data.prefs.automaticJournalAbbreviations);
|
||||
this.style = getStyle.getCiteProc(data.style.locale, this.outputFormat, {
|
||||
automaticJournalAbbreviations: data.prefs.automaticJournalAbbreviations,
|
||||
noCache: true,
|
||||
});
|
||||
this.styleClass = getStyle.class;
|
||||
// We're changing the citeproc instance, so we'll have to reinsert all citations into the registry
|
||||
this.rebuildCiteprocState = true;
|
||||
|
|
|
|||
|
|
@ -700,9 +700,23 @@ Zotero.Style = function (style, path) {
|
|||
* Get a citeproc-js CSL.Engine instance
|
||||
* @param {String} locale Locale code
|
||||
* @param {String} [format] Output format one of [rtf, html, text]
|
||||
* @param {Boolean} [automaticJournalAbbreviations] Whether to automatically abbreviate titles
|
||||
* @param {GetCiteProcOptions | boolean} [options] If passed as a boolean, sets automaticJournalAbbreviations
|
||||
* @param {boolean} [options.automaticJournalAbbreviations] Abbreviate publication titles automatically
|
||||
* @param {boolean} [options.noCache] Don't read or write the CSL.Engine cache. This should only be used in code that
|
||||
* relies on the CSL.Engine's internal state to persist properties between citation/bibliography generations.
|
||||
* Callers that will only use the CSL.Engine instance once should always take advantage of the cache.
|
||||
*
|
||||
* @typedef {{
|
||||
* automaticJournalAbbreviations?: boolean;
|
||||
* noCache?: boolean;
|
||||
* }} GetCiteProcOptions
|
||||
*/
|
||||
Zotero.Style.prototype.getCiteProc = function (locale, format, automaticJournalAbbreviations) {
|
||||
Zotero.Style.prototype.getCiteProc = function (locale, format, options = {}) {
|
||||
if (typeof options === 'boolean') {
|
||||
options = { automaticJournalAbbreviations: options };
|
||||
}
|
||||
let { automaticJournalAbbreviations, noCache } = options;
|
||||
|
||||
locale = locale || Zotero.locale || 'en-US';
|
||||
format = format || 'text';
|
||||
automaticJournalAbbreviations = !!automaticJournalAbbreviations;
|
||||
|
|
@ -711,7 +725,7 @@ Zotero.Style.prototype.getCiteProc = function (locale, format, automaticJournalA
|
|||
|
||||
// We can cache the Engine instance if we aren't using citeproc-rs
|
||||
// and this is an installed style
|
||||
let cacheKey = !useCiteprocRs && this.path
|
||||
let cacheKey = !noCache && !useCiteprocRs && this.path
|
||||
? JSON.stringify({ locale, format, automaticJournalAbbreviations })
|
||||
: null;
|
||||
if (cacheKey && this._cachedEngines.has(cacheKey)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue