Thursday, February 05, 2009

Pretty tables

I was wondering if I could make tables that were entered via a CMS have special formatting (alternating line color, custom header) without making the user entering the table via the CMS have to tag the rows or cells with classes. And yes, Nate, these really are tables...

So I thought I could use regular expressions to parse the content block and pull out tables, parse through the lines of the table and automatically set the class of the tr. I was able to come up with some code to do this, and it seems to work pretty well. Remember to put "using System.Text.RegularExpressions;" at the top of your file.


prettytable.txt

An example? This was a table with no formatting:

Labels: , , , , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home