I have been tinkering with all kinds of stuff for formatting text for the past week. I’ve lost hours trying to stare at silly ways to parse text, to concatenate files, XML transforms with XSLT, pyp command strings, etc. It’s all been interesting, but everything seemed like hard work. I might as well just use Tumblr for unimportant gibberish and then just manually code my site that just hosts a demo reel, and resume since it’s really not anything I’m constantly iterating on.
The one useful thing that has come out of this is a pyp command to parse tables the way I want them parsed, and not the way Markdown wants them parsed. Tables in all the markdown variants are horrendous for anything more complicated than a small demo table with a couple cells and rows. None of them support line breaks either
Example from MultiMardown’s docs:
| | Grouping || First Header | Second Header | Third Header | ------------ | :-----------: | -----------: | Content | Long Cell || Content | Cell | Cell |
New section | More | Data | And more | And more |
I think it’s a logical approach to handle the data like line-by-line, instead of creating weird ASCII art, or having to manually code
<tr> and escaping. (Note: MMD, and other variants use spaces to control text alignment with in cells, but I think it just makes it harder to read the table at a glance. I kept all my text alignment in my CSS instead, it’s cleaner.)
| _Column 1 Row 1<br>Line 2 _Column 2 Row 1<br>Line 2 | _Column 1 Row 2<br>Line 2 _Column 2 Row 2<br>Line 2
Run that text through this pyp string and you have a HTML string that can be placed in your markdown file, or in the final HTML file.
cat $FILE "| pyp ' p.startswith("_") or p.startswith("|") | p.replace("_", "<td>") + "</td>" | pp.delimit("|</td>")[1:80] | "<tr>" + p + "</tr>" | pp.oneline() | "<table border='0'>" + p + "</table>"'
Using a pyp command was quick & dirty for prototyping what I wanted. Ideally I will do this in a “proper” way at some point in the future.
Granted, tables aren’t the kind of thing that people are really interested in handling in Markdown to begin with.