Python Markdown: rewrite cell_row_span extension
cell_row_span
rewrite
This week I re-wrote the cell_row_span
extension. The previous version
subclassed the tables
extension, which in my opinion was the “correct” way
of doing it. However, thinking further on it, I decided it wasn’t the best
way. Subclassing has the disadvantage of leaving any future extension to the
tables
processing being unable to use both cell_row_span
and its own code.
The last extension to perfom the subclassing would override the previous one,
so either the cell_row_span
code or the other code would simply become
unrachable at run time.
Instead, cell_row_span
now hooks into the block processor before table
runs,
capturing the blocks table
wants to operate on. Later a tree processor runs
that locates all the tables in the document tree, and alters them as needed using
the text blocks captured by the block processor.