case "ArrayObject":
case "ArrayIterator":
case "RecursiveArrayIterator":
+ case "SeekableIterator":
case "SplObserver":
case "SplSubject":
case "SplObjectStorage":
+ case "JsonSerializable":
return "<code>";
// keywords
return "<a href=\"" + s.replace(/::|\\/g, "/") + "\">";
}
}
- if (-1 !== (j = s.indexOf("\\")) && s.substr(j+1,1) !== "n") {
- return "<a href=\"" + s.replace(/\\/g, "/").replace(/::|$/, "#") + "\">";
+ if (-1 !== (j = s.lastIndexOf("\\")) && s.substr(j+1,1) !== "n") {
+ t = s.substring(j+1);
+ if (!mdref.is_constant(t) || s.match(/\\/g).length <= 1) {
+ return "<a href=\"" + s.replace(/\\/g, "/").replace(/::/, "#") + "\">";
+ }
+ return "<a href=\"" + s.substring(0,j).replace(/\\/g, "/") + "#" + t + "\">";
}
switch (s.toLowerCase()) {
return "<span class=\"constant\">";
}
},
- 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);
},
walk: function walk(i, e) {
// mdref.log("walk", i, e);
+ switch (e.nodeName) {
+ case "H1":
+ case "H2":
+ case "H3":
+ case "H4":
+ case "H5":
+ case "H6":
+ if (e.id.length) {
+ var href = document.location.pathname;
+ var perm = $("<a class=\"permalink\" href=\""+href+"#\">#</a>");
+ if (e.nodeName === "H1") {
+ perm.prependTo(e);
+ } else {
+ perm.attr("href", function(i, href) {
+ return href + e.id;
+ });
+ perm.appendTo(e);
+ }
+ }
+ break;
+ }
+
$.each($.makeArray(e.childNodes), function(i, n) {
switch (n.nodeName) {
case "A":
case "BR":
case "HR":
+ case "EM":
+ case "CODE":
+ case "SPAN":
break;
case "#text":
mdref.wrap(n, e.nodeName);
},
hashchange: function hashchange() {
if (location.hash.length > 1) {
- var hash = location.hash.substring(1);
- var name = mdref.is_variable(hash) ? ".var" : ".constant";
- var scrolled = false;
+ var e;
+ if ((e = document.getElementById(location.hash.substring(1)))) {
+ mdref.blink(e);
+ } else {
+ var hash = location.hash.substring(1);
+ var name = mdref.is_variable(hash) ? ".var" : ".constant";
+ var scrolled = false;
- $(name).each(hash.substring(hash.length-1) === "_" ? function(i, c) {
- if (c.textContent.substring(0, hash.length) === hash) {
- if (!scrolled) {
+ $(name).each(hash.substring(hash.length-1) === "_" ? function(i, c) {
+ if (c.textContent.substring(0, hash.length) === hash) {
+ if (!scrolled) {
+ $(window).scrollTop($(c).offset().top - 100);
+ scrolled = true;
+ }
+ mdref.blink(c);
+ }
+ } : function(i, c) {
+ if (c.textContent === hash) {
$(window).scrollTop($(c).offset().top - 100);
- scrolled = true;
+ mdref.blink(c);
+ return false;
}
- mdref.blink(c);
- }
- } : function(i, c) {
- if (c.textContent === hash) {
- $(window).scrollTop($(c).offset().top - 100);
- mdref.blink(c);
- return false;
- }
- });
+ });
+ }
}
}
};
-
- $("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();
});