From 07f151771210f70c58a6d65e4969b261017eb94d Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Tue, 12 Jul 2022 12:00:15 +0300 Subject: [PATCH] Don't include quotes when {{highlight}} is placed in a blockquote Fixes #2697 --- chrome/content/zotero/xpcom/editorInstance.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/editorInstance.js b/chrome/content/zotero/xpcom/editorInstance.js index 155507fb4f..d253388ad1 100644 --- a/chrome/content/zotero/xpcom/editorInstance.js +++ b/chrome/content/zotero/xpcom/editorInstance.js @@ -1359,6 +1359,14 @@ class EditorInstanceUtilities { template = '

{{image}}
{{citation}} {{comment}}

'; } + Zotero.debug('Using note template:'); + Zotero.debug(template); + + template = template.replace( + /(
[^<>]*?)({{highlight}})([\s\S]*?<\/blockquote>)/g, + (match, p1, p2, p3) => p1 + "{{highlight quotes='false'}}" + p3 + ); + let vars = { color: annotation.color || '', // Include quotation marks by default, but allow to disable with `quotes='false'` @@ -1368,8 +1376,7 @@ class EditorInstanceUtilities { image: imageHTML, tags: (attrs) => (annotation.tags && annotation.tags.map(tag => tag.name) || []).join(attrs.join || ' ') }; - Zotero.debug('Using note template:'); - Zotero.debug(template); + let templateHTML = Zotero.Utilities.Internal.generateHTMLFromTemplate(template, vars); // Remove some spaces at the end of paragraph templateHTML = templateHTML.replace(/([\s]*)(<\/p)/g, '$2');