Issue multiple references in text to same citations + FIX
-
Hi, we found an issue on pages that reference the same (combination of) citations more than once. This is what we found in our research:
ISSUE
- List of citations is somehow duplicate in
<span class="ZP_ITEM_KEY">
. This causes multiple runs over same citation refs becauseintext_citations
collection now contains duplicate number of references (as it uses.ZP_ITEM_KEY
as source). - The duplicate run is fine if there’s no more than 1 of same citation (or combination of citations) inside the text.
- However, if there’s more than 1 citation (of combination of citations), then
intextGroupTracker
code comes into play (fromzotpress.shortcode.intext.js
). This piece of code relies on index increase for every loop iteration to lookupintext_citation_params
. As ZP_ITEM_KEY contains duplicate list and we have no proper checks in the lookup of intext_citation_params, the script tries to lookup at an index that does not exist. This causes a crash in zotpress.shortcode.intext(.min).js with message likecan't access property "replace", jQuery(...).attr(...) is undefined
FIX (my suggestion):
Make code forintext_citation_params
more resilient for incorrect index (basically for any unexpected list input fromZP_ITEM_KEY
). Adjust inzotpress.shortcode.intext.js
:
OLD (line 353):// OLD (line 353) var intext_citation_params = JSON.parse( jQuery("."+intext_citation_id+":eq("+intext_group_index+")", $postRef ).attr("rel").replace( /'/g, '"') );
NEW (line 353+):
var $intext_citation = jQuery("."+intext_citation_id+":eq("+intext_group_index+")", $postRef ); if ($intext_citation.length === 0 || $intext_citation.attr("rel") === undefined) { console.warn('zp: no valid intext citation ref found at index', intext_citation_id, intext_group_index); return; } var intext_citation_params = JSON.parse($intext_citation.attr("rel").replace( /'/g, '"') );
TODO (idea)
Find out maybe whyZP_ITEM_KEY
element may contain duplicate list (we have not researched this). Having duplicate list in here may cause other issues as well?It would be nice if you could add this fix to the a new release of the plugin. It would help us a great deal. Thanks!
- List of citations is somehow duplicate in
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Issue multiple references in text to same citations + FIX’ is closed to new replies.