More on Umbraco, TinyMCE and Flash
This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.
In a previous post Shannon explained how to customise TinyMCE for what HTML elements Flash actually supports, and he finished off the post with showing how to cleanup line breaks. To do this he used an XSLT function called normalize-space, which is great if you’re using XSLT!
I was writing a service today which was using LINQ to XML to generate the XML for Flash, but that posed a problem, how do you deal with Flash wanting to do hard breaks on new line constants?
Easy, string.Replace to the rescue!
Here’s a handy little extension method you can drop into your code libraries:
public static string NormalizeSpace(this string s) { if(s == null) throw new ArgumentNullException("s"); return s.Replace("\r\n", string.Empty) .Replace("\r", string.Empty) .Replace("\n", string.Empty); }
Nice and easy (and unsurprisingly logical!).
comments powered by Disqus