MarkdownDeep Plain Text Rendering

Thursday, February 3rd, 2011     #markdowndeep #everything

This might seem a little counter-intuitive, but the C# version of MarkdownDeep can now render Markdown content to plain text! Little summary previews are now easy...

Why? Primarily for preview summary of blog articles in Jab. On the Jab archive page that I've just implemented I thought it would be nice to provide a little one line summary of the post's content. Not only did I want the markdown formatting removed, I also needed a way to limit the content length.

To support this, the MarkdownDeep.Markdown object now has a new property called SummaryLength. When set to zero, MarkdownDeep performs as before and transforms Markdown to HTML. When the SummaryLength property is set the input is transformed into "cleaned" plain text.

If SummaryLength is set to -1, all the input is transformed. If it's set to a positive value, after rendering that many characters, the rendering stops and returns what's been generated. For performance reasons, the length checks are only done after each markdown paragraph so you might get back more characters but you can easily crop it yourself and append ellipsis.

« Older - Jab - Bulk file download with DotNetZip Newer - Jab - Archive Page »