1

I have created a visualforce page which displays a rich text field from my custom object, the field contains html tags for formatting which I would like to strip out as I will be cutting off the text after x characters which may cause issues if there are any unclosed html tags.

Here is my code at the moment:

<apex:outputText class="text-excerpt" value="{!left(article.Content__c,300)}" />
3

2 Answers 2

0

In your scenario, you could try doing this (use escape attribute)

<apex:outputText class="text-excerpt" value="{!left(article.Content__c,300)}" escape="false" />
1
  • Wouldn't that do the opposite of what I want? that wont the escape the html tags which means they could be leave unclosed tags Oct 10, 2014 at 15:09
2

The System.String class has a 'stripHtmlTags' method.

Removes HTML markup from the input string and returns the plain text.

2
  • Daniel, adding some more text or explanation will increase the meaning of your answer. For instance: I've gone ahead and included a quote out of the docmentation that you refered to. Oct 12, 2014 at 21:31
  • This was my first answer so just went for it. Thank you for your help Samuel. Oct 12, 2014 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .