How to Generate RPE report (with IBM RDNG data source) with table caption being printed in center
3 answers
As a author of the workaround in the ticket I think I should answer this.
For the text element that is displaying the text you should add following code.
var match = {};
var patt = /(<table[^>]>(<caption[^>]>(?:.|\n)?<\/caption>)?(?:.|\n)?<\/table>)/g;
while ((match = patt.exec(div))) {
var table = match[1];
var caption = match[2];
if (caption)
{
table = table.replace(caption, "");
table = '<div style="text-align:center;"><span>Table '+caption+"</span></div>" + table;
div = div.replace(match[1], table);
}
}
var patt = /(<table[^>]>(<caption[^>]>(?:.|\n)?<\/caption>)?(?:.|\n)?<\/table>)/g;
while ((match = patt.exec(div))) {
var table = match[1];
var caption = match[2];
if (caption)
{
table = table.replace(caption, "");
table = '<div style="text-align:center;"><span>Table '+caption+"</span></div>" + table;
div = div.replace(match[1], table);
}
}
This code is moving <caption> to span outside of the table (before it). That is only way how I was able to implement it.
Prashant mentioned the ticket which was requested opened by me
The workaround provided by Bartosz is good. You can find the modified template UAS-Functional-SPP.dta that will center-align the table captions.
You can also try the macro solution (works only for Word output and not for PDF output).
Comments
Subramanya,
You are wrong because you will be able to generate list of tables using this workaround. If You will read the code carefull it is talking <caption></caption> outside the table and encapsulate this in centered span.
This will still generate properly working ToT. You can check this by yourself or I can provide working example.
Good to know that. Sorry, I should have checked it before commenting. :)
Hi Bartosz,
I tried doing it the workaround it did not work, can you please provide working sample
Regards,
Prashanth
Prashanth
Hi Bartosz,
I tried doing it the workaround it did not work, can you please provide working sample or please provide the work instructions to implement it in RPE template
Regards,
Prashanth
Prashanth
You should return div, else Script Expression will retun undefined value.
var match = {};
var patt = /(<table[^>]*>(<caption[^>]*>(?:.|\n)*?<\/caption>)?(?:.|\n)*?<\/table>)/g;
while (match = patt.exec(div)) {
var table = match[1];
var caption = match[2];
if (caption)
{
table = table.replace(caption, "");
table = '<div style="text-align:center;"><span>'+caption+"</span></div>" + table;
div = div.replace(match[1], table);
}
}
div;
var patt = /(<table[^>]*>(<caption[^>]*>(?:.|\n)*?<\/caption>)?(?:.|\n)*?<\/table>)/g;
while (match = patt.exec(div)) {
var table = match[1];
var caption = match[2];
if (caption)
{
table = table.replace(caption, "");
table = '<div style="text-align:center;"><span>'+caption+"</span></div>" + table;
div = div.replace(match[1], table);
}
}
div;