Archive

Archive for November, 2010

A Parser for Formatted Text in WPF / Silverlight

November 5th, 2010

I finally got round to implement on-the-fly text formatting for Sketchables, which will  allow you to define text formatting while typing (similar to wikis or forum posts). Sketchables will parse such strings and format them on the fly for you:

the star renders *bold* text

I didn’t rely on regular expressions here, but wrote a simple forwarding parser to process markup text. As it makes a pretty neat tool, I extracted it into a little sample app that shows a possible use for it. The presented implementation just creates nested text blocks, but you should be able to easily adjust it to your needs.

 

image

Latest Update:  2010.11.07 – Fixed issue with single character chunks.

Download Sample Application