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)}" />
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" />
  • 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 – Deployment Failure Oct 10 '14 at 15:09
2

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

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

  • 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. – Samuel De Rycke Oct 12 '14 at 21:31
  • This was my first answer so just went for it. Thank you for your help Samuel. – daniel.huckins Oct 12 '14 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.