Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
@Umbraco.Truncate("<p><strong> this is my really really really really really really short blog post</strong></p>",10,false)
<p><strong this is</strong></p></div>
Notice the open strong tag is broken. Has anyone else noticed this? About to just roll my own.
I'm pretty sure there is method in here that would do the job properly.
Another approach is to leverage Tidy... I found you have to help a little for when the trunacte causes a break in a tag, but quite straight forward..
Sorry could only find xslt example.. but should apply in razor or usercontrol too..
<!-- we may be splitting mid tag!! -->
<xsl:value-of select="substring(umbraco.library:GetXmlNodeById($nodeId)/abstract, 1, $abstractLength)" disable-output-escaping="yes"/>
<!-- help tidy out by removing any unclosed tag at the end of the string not so hot at this itself -->
<xsl:variable name="regExp"><xsl:text disable-output-escaping="yes">[\s\S]*>[^<]*</xsl:text></xsl:variable>
<xsl:value-of disable-output-escaping="yes" select="umbraco.library:Tidy(Exslt.ExsltRegularExpressions:match($xmlFragment, $regExp), false)" />
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted