Strip tags from shortdesc (et al.) when parsing

This strips markup from elements with id attributes that we care about: title, shortdesc, tags.  This will only work for people who use `npm install && npm start` to browse examples.  The other example parser doesn't strip this markup, so it should still not be used in these elements.
This commit is contained in:
Tim Schaub
2014-04-04 10:00:23 -06:00
parent 2a4300085e
commit 6fc915ba7b

View File

@@ -49,21 +49,25 @@ function parseExamples(examplePaths, callback) {
tags: ''
};
var key;
var openTag;
var parser = new Parser({
onopentag: function(name, attrs) {
onopentag: function(tag, attrs) {
if (attrs.id in info) {
key = attrs.id;
} else {
key = undefined;
openTag = tag;
}
},
ontext: function(text) {
if (key) {
info[key] = text.replace(/\n/g, '').trim();
info[key] += text.replace(/\n/g, '').trim() + ' ';
}
},
onclosetag: function(name) {
key = undefined;
onclosetag: function(tag) {
if (tag === openTag) {
info[key] = info[key].trim();
key = undefined;
openTag = undefined;
}
},
onerror: function(err2) {
var message = 'Trouble parsing ' + examplePath + '\n' + err2.message;