Supporting markdown in applications

In just about every application I’ve ever developed, there’s at least one multi-line text box that takes free form input from the user. In some applications (such as email, Twitter, log entry, etc.) this might be the primary use case. In other applications it might be a simple “description” box hidden away in a properties dialog.

But in any case, it’s always a challenge to use anything more than plain text for a variety of reasons. First of all, even though WPF, Silverlight, and Windows Forms all have built-in rich text controls, they lack the basic UI elements such as toolbars for formatting. In web applications it’s even worse because there is no native rich text control so you gotta find a component.

Then there is the issue of what to do with the data. Windows Forms produces RTF formatted text. WPF and Silverlight produce XAML. Web browsers produce HTML. But these three formats aren’t easily interchangeable and they all suffer from the fact that they look terrible when circumstances require you to present it as plain text.

There is a solution! It’s called markdown. And it’s something you’ve probably used before if you’ve ever used StackOverflow.

With markdown, you can input and store the content as plain text but render it as rich formatted text. The advantage over markup such as HTML is that the syntax is designed to be very readable as plain text. And since the formatting characters are so intuitive and natural, you don’t need superfluous toolbars or menus to format your content. Since there is no need to strip the formatting when displaying as plain text, you don’t need to worry about how it looks on devices or application screens that don’t support rich text.

Markdown

Of course it’s not HTML so it doesn’t support anything like layout or complicated formatting. It’s simply rich text. But it does support links, headings, lists, and images. You can refer to John Gruber’s markdown page for a more thorough explanation of where and how markdown fits in the context of HTML.

So I’m making more of an effort to support and promote markdown everywhere that I use multi-line text boxes and hopefully you’ll consider it too. I set up a WordPress plugin created by Michel Fortin that allows me to compose my posts in markdown. Now I can write blog posts on my iPad much more easily. Next I’ll be looking for ways to translate markdown to XAML FlowDocuments so that I can use it in WPF and Silverlight applications.