SHJS strips <br/> tags from the text.
While they are not necessary within a <pre> tag, they're still allowed there. I encountered that problem when I integrated SHJS into phpBB3. phpBB3 automatically replaces all newlines in the post by <br/> tags.
The solution is quite simple, I only added two lines to the sh_getText() function in sh_main.js:
function sh_getText(element) {
// only works in some browsers
// if (element.nodeType === element.TEXT_NODE ||
// element.nodeType === element.CDATA_SECTION_NODE) {
if (element.nodeType === 3 ||
element.nodeType === 4) {
return element.data;
}
else if (element.nodeType === 1 && element.tagName === "BR" )
return "\r\n";
else if (element.childNodes.length === 1) {
return sh_getText(element.firstChild);
}
else {
var result = '';
for (var i = 0; i < element.childNodes.length; i++) {
result += sh_getText(element.childNodes.item(i));
}
return result;
}
}
Maybe this should be added to the next release so that it is possible to use SHJS with phpBB3 (and most other software that allows user-generated content).
Logged In: YES
user_id=1294975
Originator: NO
This should be fixed in version 0.5.