How do you remove the carriage return in front of RTF rendered text in RPE?
Here is my dilemma, I have tried several ways to remove a <cr> from the RTF/XHTML string for a given artifact. But no matter what I have tried I have failed. We have a requirement format in our documents of:
[HLR#1234] Some requirement here.
But what I end up with is:
[HLR#1234]
Some requirement here.
I was building the output with RPE and Text Blocks. Now I have tried to concatenate in a Java Script. Same result.
Here is my Java Script:
div = div.replace(/<p[^>]*>/g,""); // remove paragraph tag
div = div.replace(/<\/p[^>]*>/g,"");
div = div.replace(/<span[^>]*>/g,""); // remove span tag
div = div.replace(/<\/span[^>]*>/g,"");
div = div.replace(/<a[^>]*>/g,""); // remove hyperlinks
div = div.replace(/<\/a[^>]*>/g,"");
div = div.replace(/<i[^>]*>/g,"<i>"); // preserve italics, but remove anything else
div = div.replace(/<b[^>]*>/g,"<b>"); // preserve bold, but remove other stuff
div = div.replace(/^\s/g,""); // remove initial hidden characters
var this_req_type = "[HLR#";
if ( _is_safety == "true") {
this_req_type = "[HLS#";
} else if ( _is_derived == "true" ) {
this_req_type = "[HDR#";
}
div = "<b>" + this_req_type + _req_number + "]</b> " + div;
|
Accepted answer
The line break you are getting is because of the div tag (left after removing paragraph, span tags). One option is to remove div as well so that Script Expression becomes
div = div.replace(/<div[^>]*>/g,""); // remove div tag div=div.replace(/<\/div[^>]*>/g,""); div = div.replace(/<p[^>]*>/g,""); // remove paragraph tag div = div.replace(/<\/p[^>]*>/g,""); div = div.replace(/<span[^>]*>/g,""); // remove span tag div = div.replace(/<\/span[^>]*>/g,""); div = div.replace(/<a[^>]*>/g,""); // remove hyperlinks div = div.replace(/<\/a[^>]*>/g,""); div = div.replace(/<i[^>]*>/g,""); // preserve italics, but remove anything else div = div.replace(/<b[^>]*>/g,""); // preserve bold, but remove other stuff div = div.replace(/^\s/g,""); // remove initial hidden characters var this_req_type = "[HLR#"; if ( _is_safety == "true") { this_req_type = "[HLS#"; } else if ( _is_derived == "true" ) { this_req_type = "[HDR#"; } div = "" + this_req_type + _req_number + "] " + div; div; Again, please note that if the Script Expression returns invalid XML, document generation stops with an error. David Clark selected this answer as the correct answer
Comments
David Clark
commented Jun 11 '16, 7:06 p.m.
Thank you, finally this problem has been addressed. David |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.