go.talks: use a more robust method to gather snippet text
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/14175043
diff --git a/present/js/play.js b/present/js/play.js
index 048ff2f..7e87460 100644
--- a/present/js/play.js
+++ b/present/js/play.js
@@ -9,17 +9,20 @@
var s = "";
for (var i = 0; i < node.childNodes.length; i++) {
var n = node.childNodes[i];
- if (n.nodeType !== 1) continue;
- if (n.tagName === "BUTTON") continue;
- if (n.tagName === "SPAN" && n.className === "number") continue;
- if (n.tagName === "PRE"){
+ if (n.nodeType === 1) {
+ if (n.tagName === "BUTTON") continue
+ if (n.tagName === "SPAN" && n.className === "number") continue;
+ if (n.tagName === "DIV" || n.tagName == "BR") {
+ s += "\n";
+ }
s += text(n);
continue;
}
- var innerText = n.innerText === undefined ? "textContent" : "innerText";
- s += n[innerText] + "\n";
+ if (n.nodeType === 3) {
+ s += n.nodeValue;
+ }
}
- return s;
+ return s.replace("\xA0", " "); // replace non-breaking spaces
}
function init(code) {