Apologies if this has been answered before. I want to display the first 300 characters of a rich text editor and have done the following (which works fine).
What I would like to do after this is to strip out all images, styling and links. Is there any way I can grab all the outputted text and the strip out all code so it's just plain text?
The reason I put the disable-output-escaping on in the first place is so I don't get any of the html code being pulled in, but it throws in pictures and links and looks unsightly.
xslt render html
Hey,
Apologies if this has been answered before. I want to display the first 300 characters of a rich text editor and have done the following (which works fine).
What I would like to do after this is to strip out all images, styling and links. Is there any way I can grab all the outputted text and the strip out all code so it's just plain text?
The reason I put the disable-output-escaping on in the first place is so I don't get any of the html code being pulled in, but it throws in pictures and links and looks unsightly.
Any help would be much appreciated!
Thanks,
Tom
Hi Tom,
There is also a
StripHtml()
extension that you could try to combine withTruncateString()
(do the stripping first).(And then remove the
disable-output-escaping
attribute again)Hope that helps,
/Chriztian
Perfect - exactly what I was looking for.
Updated code for anyone who may need it in the future (not sure if you can combine the two for a neater solution, but this was the method I used):
Thanks as always for the quick response Chriztian!
No worries, Tom :-)
You can combine into a single line, but there's no penalty for creating a variable first - only improves the readability of the second line, IMO.
/Chriztian
is working on a reply...