BenEngbers / asciidoc

Automatically exported from code.google.com/p/asciidoc
GNU General Public License v2.0
0 stars 0 forks source link

[Patch] The reinstall timer breaks footnoterefs (asciidoc.js) #30

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If the asciidoc.footnotes() function is called twice (such as if the reinstall 
timer is triggered), then all footnoterefs are renumbered to 'undefined' and 
broken. The attached patch solves this by only renumbering footnoterefs when a 
valid number is found for them:

diff -r 7863b0a0ab0d -r 1dad4b041c4a javascripts/asciidoc.js
--- a/javascripts/asciidoc.js   Wed Nov 27 21:59:21 2013 +1300
+++ b/javascripts/asciidoc.js   Tue Apr 15 09:09:29 2014 -0600
@@ -156,9 +156,11 @@
         var href = spans[i].getElementsByTagName("a")[0].getAttribute("href
         href = href.match(/#.*/)[0];  // Because IE return full URL.
         n = refs[href];
-        spans[i].innerHTML =
-          "[<a href='#_footnote_" + n +
-          "' title='View footnote' class='footnote'>" + n + "</a>]";
+        if (n) {
+          spans[i].innerHTML =
+            "[<a href='#_footnote_" + n +
+            "' title='View footnote' class='footnote'>" + n + "</a>]";
+        }
       }
     }
   }

Original issue reported on code.google.com by cristo...@gmail.com on 15 Apr 2014 at 3:39

Attachments: