mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Normalise line endings in xml output.
This commit is contained in:
parent
b4115bd6d6
commit
e5cf855194
@ -30,9 +30,9 @@ var json2xml = (typeof exports === 'undefined')? {} : exports; // like commonjs
|
||||
if (hasChild) {
|
||||
for (var m in v) {
|
||||
if (m == "#text")
|
||||
xml += v[m];
|
||||
xml += lines(v[m]);
|
||||
else if (m == "#cdata")
|
||||
xml += "<![CDATA[" + v[m] + "]]>";
|
||||
xml += "<![CDATA[" + lines(v[m]) + "]]>";
|
||||
else if (m.charAt(0) != "@")
|
||||
xml += toXml(v[m], m, ind+"\t");
|
||||
}
|
||||
@ -40,7 +40,7 @@ var json2xml = (typeof exports === 'undefined')? {} : exports; // like commonjs
|
||||
}
|
||||
}
|
||||
else { // added special-character transform, but this needs to be better handled [micmath]
|
||||
xml += ind + "<" + name + ">" + v.toString().replace(/</g, '<').replace(/&/g, '&') + "</" + name + ">\n";
|
||||
xml += ind + "<" + name + ">" + makeSafe(lines(v.toString())) + "</" + name + ">\n";
|
||||
}
|
||||
return xml;
|
||||
},
|
||||
@ -52,5 +52,19 @@ var json2xml = (typeof exports === 'undefined')? {} : exports; // like commonjs
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
function lines(str) {
|
||||
// normalise line endings, all in file will be unixy
|
||||
str = str.replace(/\r\n/g, '\n');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function makeSafe(str) {
|
||||
// xml special charaters
|
||||
str = str.replace(/</g, '<').replace(/&/g, '&');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user