Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Removing the <p> tags that surround VF content
Gregg Faus
How can the <p> tags that surround the entire Visual Format Editor content be removed?
Find more posts tagged with
Comments
tobias
I remove these nasty <p> tags with the following code in the *.tpl presentation templates:
<iw_perl><![CDATA[
if ($text = iwpt_dcr_value('dcr.Text')) {
$text =~ s/<p[^>]*>//g;
$text =~ s/<\/p>/<br>/g;
iwpt_output ($text);
}
]]></iw_perl>
As you can see I remove each opening <p> tag and replace the closing </p> tags with a <br> each before I put out the text. This works quite well, though I'd like Interwoven to provide a standard solution for this.
(If you're using "copy and paste" from MSOffice docs, a number of <span> tags will be created automatically which can ruin your presentation template's settings, therefore I also remove these tags with the following line:
$text =~ s/<\/?span[^>]*>//g;
Hope this helps you.
Regards,
Tobias
gsumers22texas
question about your code snippet: what's the relationship of the <iw_perl> element and regexes within it within the tpl? do you just insert it once globally within the tpl? if so where? does it matter? or once per <textarea> item you want to control? any effect on it's use for <textarea> within a replicant?
tobias
I think you'll have to insert the perl code for each textarea, at least that's the way I do it.
I haven't created any DCRs with replicant textareas, so I don't know what effect the perl might have on multiple ocurrences, but I'm gonna try it and let you know.
gsumers22texas
has anybody gotten this regex "snipping" of <p> and </p> tags within Visual Formatted textareas to work within replicated fields?
We insert the recommended regex, it works for the first item in the replicant, but all following items have them still? also, even when the <p> and </p> tags are stripped, there still seems to be whitespace added between the items ?
vijaya
Including the following code removes the <p></p> tags within nested
replicants.
<iw_iterate list='offices.Address' var='address'>
<iw_perl>
<![CDATA[
if($AddressText =iwpt_dcr_value(address.AddressText')) {
$AddressText =~ s/<p[^>]*>//g;
$AddressText =~ s/<\/p>/<br>/g;
iwpt_output ("$AddressText");
}
]]>
</iw_perl>
</iw_iterate>
nico
got a way of just removing the opening and closing <p> and </p> tag?
JonathonG
Pretty sure you should be able to do:
$str =~ s/^\s*<p>//s;
$str =~ s/<\/p>\s*$//s;
to remove just the opening and closing paragraph tags from around a VF field.
The "s" modifier tells Perl to treat the string as one long line, ignoring any inter-vening newlines so that ^ matches strictly at the beginning of the string and $ strictly at the end.
Haven't tested this, but it's similar to some other stuff I've done.
Hope it helps.
Jonathon
Interwoven Architecture Consultant
Migrateduser
Unfortunately this might not work if you are using something other than Perl to parse the XML, for instance I imagine DataDeploy or an XML parser. I suggest using onSave events before the <P> is ever saved to the DCR to scrub VFE-enabled fields. You may find that <P> is not your only problem anyway.