X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=public%2Findex.js;h=7c5a82c24043d6d5da63e41c3dfb5b1b631bd4aa;hb=904fc60f05894d6207e9ae85abda8c94283f7d28;hp=62ccba63c8ffd9eac673bc40e8dbdd69a2c49079;hpb=2ee2dacaf6f40f6feb1201720927b6b7e7b873f1;p=mdref%2Fmdref diff --git a/public/index.js b/public/index.js index 62ccba6..7c5a82c 100644 --- a/public/index.js +++ b/public/index.js @@ -55,9 +55,11 @@ $(function() { case "ArrayObject": case "ArrayIterator": case "RecursiveArrayIterator": + case "SeekableIterator": case "SplObserver": case "SplSubject": case "SplObjectStorage": + case "JsonSerializable": return ""; // keywords @@ -95,8 +97,12 @@ $(function() { return ""; } } - if (-1 !== (j = s.indexOf("\\")) && s.substr(j+1,1) !== "n") { - return ""; + if (-1 !== (j = s.lastIndexOf("\\")) && s.substr(j+1,1) !== "n") { + t = s.substring(j+1); + if (!mdref.is_constant(t) || s.match(/\\/).length <= 1) { + return ""; + } + return ""; } switch (s.toLowerCase()) { @@ -117,20 +123,24 @@ $(function() { return ""; } }, - node: function node(s, nn) { - // mdref.log("node", s); - var t; - if ((t = mdref.type(s, nn))) { - return $(t).text(s); - } - return document.createTextNode(s); - }, wrap: function wrap(n, nn) { var $n = $(n) var a = []; $n.text().split(/([^a-zA-Z0-9_\\\$:]+)/).forEach(function(v) { - a.push(mdref.node(v, nn)); + var t; + + if ((t = mdref.type(v.replace(/:$/, ""), nn))) { + a.push($(t).text(v)); + } else if (a.length && a[a.length-1].nodeName === "#text") { + /* if we already have a text node and the next is also gonna be a text + * node, then join them, becuase chrome v30+ or something eats whitespace + * for breakfast, lunch and dinner! + */ + a[a.length-1].textContent += v; + } else { + a.push(document.createTextNode(v)); + } }); $n.replaceWith(a); }, @@ -142,6 +152,9 @@ $(function() { case "A": case "BR": case "HR": + case "EM": + case "CODE": + case "SPAN": break; case "#text": mdref.wrap(n, e.nodeName); @@ -188,7 +201,7 @@ $(function() { } }; - $("h1,h2,h3,h4,h5,h6,p,li,code").each(mdref.walk); + $("h1,h2,h3,h4,h5,h6,p,li,code,td").each(mdref.walk); $(window).on("hashchange", mdref.hashchange); mdref.hashchange(); });