Iterating on Better Markdown Tables

After my post yesterday I thought about it some more and decided, "I really do want these tables to look better without having to do CLI stuff."

I figured out how I wanted to loop through the document and do the selective replacements I wanted and still have Markdown that was perfectly valid for parsing.

Markdown File:

|
_**Month**
_*Day*
__Year_
|
_July
_[index.html](22)
_2012

Result:

Month

Day

Year

July

22

2012

The first version of the script did simple replacements if the line started with a "|" or "_" but this encapsulated the text in HTML tags so the Markdown characters would not evaluate when it was running through a Markdown package after the fact.

I looked up a Python Markdown package so that I could evaluate the Markdown characters per line and then encapsulate the line in the required HTML tags.

Keep in mind, I have a Bachelor of Fine Arts, so I am quite happy with myself for doing something anyone else can do better and faster. (let me have my moment)

Here is the code for doing the table loop:import markdown

Now I can put this python in to Automator and add it as a Service, or a Workflow and just easily deal with markdown I compose rather than manual work. There are some bugs with this Markdown library though. As I’ve iterated on this document I’ve seen issues with h1 and `` code not working.

2012-08-01 11:58:00

Category: text