Open cproctor opened 5 years ago
Hi @cproctor , thank you very much for your contribution.
I'm afraid right now the stargazer
code needs deeper changes (#46 ) in order to support further formats in the best way, but once we settle on the general structure it would be great if you could rebase your code: the proposed feature is definitely interesting.
Hi! This is my first ever pull request, so please let me know if I've missed some crucial etiquette. I needed regression tables for my Python/markdown-based dissertation build system, and adding it to stargazer seemed like the shortest path. Maybe someone else will benefit too! Here's a rundown of the proposed changes:
I implemented an abstract set of
generate_cells
methods, following the code paths from thegenerate_html
methods. These return a two-dimensional array of strings, which could be used for other render formats as well. (It might be valuable to refactor the html output to use this where possible.) The 2d grid of cells intentionally limits some of the functionality--no rowspans or colspans are supported.I also added a few new properties which will be valuable for anyone trying to export markdown regression tables:
The separators could be changed to
\n
, which is particularly nice because tabulate converts newlines into whatever markdown format is requested. Thesig_char
may need to be replaced by an escaped version of itself in some output contexts.Once the
generate_cells
methods were implemented, I usetabulate
(new dependency) to render these cells to ascii or any supported flavor of markdown.