Normally, while using xslt one would write the following to remove them quickly.
<umbraco:item field='property' stripParagraph='true'Not finding an equivalent function in the umbraco API, i wrote this quick-and-dirty method that works quite well for the task(at least for me). Hope it saves some time for you.
runat='server'>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static string StripParagraphTag(string input) | |
{ | |
int startPIndex = input.IndexOf("<p>"); | |
//if found a <p> tag | |
if (startPIndex != -1) | |
{ | |
//if <p> tag lies in between content, do not strip it. | |
string preP = input.Substring(0, startPIndex); | |
for (int i = 0; i < preP.Length; ++i) | |
{ | |
if (preP[i] != '\r' || preP[i] != '\n') | |
return input; | |
} | |
//if ending of p tag at end, then strip contents before | |
if (input.LastIndexOf("</p>") == input.Length - 4) | |
return input.Substring(startPIndex + 3, input.Length - (startPIndex + 3) - 4); | |
} | |
return input; | |
} |
Hi Arviman,
ReplyDeleteGreat article - I'm having exactly the same issue. Whereabouts do you place this code to strip out the content though?
Cheers,
Tony
Wow, sorry for replying super late. You'd use this in the backend wherever you're pulling data using your Node or Document object.
ReplyDelete