[SalesForce] Strip out html from excerpt

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)}" />

Best Answer

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

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