Browse Source

Account for different references when collapsing footnotes.

ief
Alexander O'Neill 6 years ago
parent
commit
dc9de6e3f0
  1. 10
      src/Plugin/Filter/ReferenceFootnotesFilter.php

10
src/Plugin/Filter/ReferenceFootnotesFilter.php

@ -184,6 +184,8 @@ class ReferenceFootnotesFilter extends FootnotesFilter {
$randstr = $this->randstr(); $randstr = $this->randstr();
$value = $this->extractAttribute($matches, 'value'); $value = $this->extractAttribute($matches, 'value');
$page = $this->extractAttribute($matches, 'page');
$reference = $this->extractAttribute($matches, 'reference');
if ($value) { if ($value) {
// A value label was found. If it is numeric, record it in $n so further // A value label was found. If it is numeric, record it in $n so further
@ -195,7 +197,7 @@ class ReferenceFootnotesFilter extends FootnotesFilter {
$n = $value; $n = $value;
} }
} }
elseif ($opt_collapse and $value_existing = $this->findFootnote($matches[2], $store_matches)) { elseif ($opt_collapse and $value_existing = $this->findFootnote($matches[2], $reference, $store_matches)) {
// An identical footnote already exists. Set value to the previously // An identical footnote already exists. Set value to the previously
// existing value. // existing value.
$value = $value_existing; $value = $value_existing;
@ -211,8 +213,6 @@ class ReferenceFootnotesFilter extends FootnotesFilter {
// attribute. // attribute.
$value_id = preg_replace('|[^\w\-]|', '', $value); $value_id = preg_replace('|[^\w\-]|', '', $value);
$page = $this->extractAttribute($matches, 'page');
$reference = $this->extractAttribute($matches, 'reference');
// Create a sanitized version of $text that is suitable for using as HTML // Create a sanitized version of $text that is suitable for using as HTML
// attribute value. (In particular, as the title attribute to the footnote // attribute value. (In particular, as the title attribute to the footnote
@ -279,10 +279,10 @@ class ReferenceFootnotesFilter extends FootnotesFilter {
/** /**
* @inheritdoc * @inheritdoc
*/ */
private function findFootnote($text, &$store_matches) { private function findFootnote($text, $reference, &$store_matches) {
if (!empty($store_matches)) { if (!empty($store_matches)) {
foreach ($store_matches as &$fn) { foreach ($store_matches as &$fn) {
if ($fn['text'] == $text) { if ($fn['text'] == $text && $fn['reference'] == $reference) {
return $fn['value']; return $fn['value'];
} }
} }

Loading…
Cancel
Save