From fedeebd7b9d2cf4666569c1d6a0897a8a87e67e5 Mon Sep 17 00:00:00 2001
From: Anika Henke <anika@selfthinker.org>
Date: Wed, 20 Apr 2016 16:01:30 +0100
Subject: [PATCH] rewrote js for footnotes to work in xhtml

---
 inc/parser/xhtml.php |  2 +-
 lib/scripts/page.js  | 19 +++++++++++--------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 236409b45..992f76344 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -147,7 +147,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
                     }
 
                     // add footnote markup and close this footnote
-                    $this->doc .= $footnote;
+                    $this->doc .= '<span class="content">'.$footnote.'</span>';
                     $this->doc .= '</div>'.DOKU_LF;
                 }
             }
diff --git a/lib/scripts/page.js b/lib/scripts/page.js
index a179ae2a8..aadff8ecf 100644
--- a/lib/scripts/page.js
+++ b/lib/scripts/page.js
@@ -83,23 +83,26 @@ dw_page = {
      *
      * @author Andreas Gohr <andi@splitbrain.org>
      * @author Chris Smith <chris@jalakai.co.uk>
+     * @author Anika Henke <anika@selfthinker.org>
      */
     footnoteDisplay: function () {
-        var content = jQuery(jQuery(this).attr('href')) // Footnote text anchor
-                      .closest('div.fn').html();
+        var $content = jQuery(jQuery(this).attr('href')) // Footnote text anchor
+                      .parent().siblings('.content').clone();
 
-        if (content === null){
+        if (!$content) {
             return;
         }
 
-        // strip the leading content anchors and their comma separators
-        content = content.replace(/((^|\s*,\s*)<sup>.*?<\/sup>)+\s*/gi, '');
-
         // prefix ids on any elements with "insitu__" to ensure they remain unique
-        content = content.replace(/\bid=(['"])([^"']+)\1/gi,'id="insitu__$2');
+        jQuery('[id]', $content).each(function(){
+            var id = jQuery(this).attr('id');
+            jQuery(this).attr('id', 'insitu__' + id);
+        });
 
+        var content = $content.html().trim();
         // now put the content into the wrapper
-        dw_page.insituPopup(this, 'insitu__fn').html(content).show().attr('aria-hidden', 'false');
+        dw_page.insituPopup(this, 'insitu__fn').html(content)
+        .show().attr('aria-hidden', 'false');
     },
 
     /**
-- 
GitLab