wp-md
wp-md copied to clipboard
Spaces in Table Formatting Row
Hi There,
Thanks for your post on formatting tables in BBEdit ( http://www.leancrew.com/all-this/2012/11/markdown-table-scripts-for-bbedit/ ).
I'm trying to use the tables as defined by the GFM tables extension spec ( https://github.github.com/gfm/#tables-extension- ) which use spaces around the pipes:
| foo | bar |
| --- | --- |
| baz | bim |
which appear to break your Normalize Table.py
script with this error:
Traceback (most recent call last):
File "/Users/levi/Dropbox (Personal)/Application Support/BBEdit/Text Filters/Normalize Table.py", line 98, in <module>
print normtable(unformatted)
File "/Users/levi/Dropbox (Personal)/Application Support/BBEdit/Text Filters/Normalize Table.py", line 35, in normtable
del lines[formatrow]
UnboundLocalError: local variable 'formatrow' referenced before assignment
I'm no python coder, but, it seems to me the formatrow
variable is unassigned because the format row was not found by the loop with that intent:
if set(lines[i]).issubset('|:.-'):
likely due to the spaces the spec suggests.
If I modify the line to include the space:
if set(lines[i]).issubset('| :.-'):
The script appears to work properly.
Please pardon the fact I didn't fork and make a pull request for this small modification. 1) that's more time than I want to commit, and 2) I'm not 100% sure this is the correct solution.
Cheers.