In my last blog post I described how Sitefinity can summarize your blog posts by enforcing an automatic cut-off point (for example, 150 words). I use this feature on Sitefinity Watch to prevent my rambling blog posts from overwhelming the main page.
Last week I noticed something concerning however.
My 150 word cut-off landed right in the middle of a code sample. The HTML used to display code samples is often ugly and contains lots of nested tags. Let's look at a quick example:
<pre class="csharpcode">
<span class="kwrd"><</span>
<span class="html">httpModules</span>
<span class="kwrd">></span>
<span class="kwrd"></</span>
<span class="html">httpModules</span>
<span class="kwrd">></span>
</pre>
Keep in mind, this is a really simple example. This is only 2 lines of code. Larger code samples will turn into an overwhelming block of HTML.
Consequently, when Sitefinity cut-off my blog post in mid-code sample I thought for sure I would see un-terminated HTML tags (tags that are opened but never closed).
Sitefinity Magic to the Rescue
When I viewed the source code for my web page I was very pleasantly surprised however. Here is what I saw:
<div>
<pre class='csharpcode'>
<span class='kwrd'>using</span> System;
<span class='kwrd'>namespace</span> MyClass
{
<span class='kwrd'>public</span>
<span class='kwrd'>class</span> Customer
{
<span class='kwrd'>private</span>
<span class='kwrd'>string</span> _firstname;
<span class='kwrd'>private</span>
<span class='kwrd'>string</span> _lastname;
<span class='kwrd'>public</span>
<span class='kwrd'>string</span> FirstName
{
...
</pre>
</div>
Sitefinity automatically closed my open HTML tags (<pre> & <div>) . I posted my delight to our internal Telerik newsgroups and Boyan Rabchev (aka "Bob") replied with the following:
"Yes, SummaryParser class is taking care for this and you can set its behavior in ContentView properties. It also allows you to filter specified HTML tags."
This is one of those "It Just Works" moments that I love experiencing.