Fixed problems with HTML entity handling

This commit is contained in:
Jeremy Ruston
2011-12-08 12:38:08 +00:00
parent 25bf2fc330
commit ef60c9018e
6 changed files with 36 additions and 7 deletions

View File

@@ -84,6 +84,9 @@ WikiTextParser.prototype.renderAsHtml = function(store,title) {
case "text":
output.push(utils.htmlEncode(tree[t].value));
break;
case "entity":
output.push(tree[t].value);
break;
case "br":
case "img":
renderElement(tree[t],true); // Self closing elements
@@ -102,8 +105,18 @@ WikiTextParser.prototype.renderAsText = function(store,title) {
var output = [];
var renderSubTree = function(tree) {
for(var t=0; t<tree.length; t++) {
if(tree[t].type === "text") {
output.push(tree[t].value);
switch(tree[t].type) {
case "text":
output.push(tree[t].value);
break;
case "entity":
var c = utils.entityDecode(tree[t].value);
if(c) {
output.push(c);
} else {
output.push(tree[t].value);
}
break;
}
if(tree[t].children) {
renderSubTree(tree[t].children);