spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
457 stars 130 forks source link

using cell metadata to get better output - especially table's #253

Open rddaz2013 opened 5 years ago

rddaz2013 commented 5 years ago

starting position I am currently using 'tabulate' to format my tables of pandas as markdown. This results in a nice readable table in HTML output - in latex the formatting only shows a normal grid box. (on display (Markdown) does not work that way). Important the tables are type 'Output'

Workaround ... for latex I modified the sphinx / writer / latex to get at least one visually acceptable table.

Idea for an extension of nbsphinx ...

Within jupyter we have metadata for the cells. In the working environment nothing would change the table can be displayed normally (without 'tabulate'). As metadata a link to a sourcefile or the data is written directly. nbsphinx checks if this metadata exists and replaces the normal output with the link from the metadata. (or via .. only :: html // ..only :: latex)

Short if an cell has a special metadata nbsphinx will take this as output.

mgeier commented 5 years ago

Thanks for your suggestion!

Could you please provide examples and/or screenshots that illustrate the situation?

rddaz2013 commented 5 years ago

Short PDF from my JupyterLab - this is the view in JupytherLab Good html table / latex table https://drive.google.com/open?id=1j2anOKF043fakQkGirtqZjukHOvFnYMn

Short PDF from the html (JupyterLab - sphinx/nbsphinx -> html) https://drive.google.com/open?id=1B_8tuXPSl5PvjS8FDWdo7zLzyNFyX6x0

Source https://drive.google.com/open?id=1j_Kbos5Bw92UmXp8DDorAcSkWJ558Awi

If we could put the outputcell (with latex code inside) direct into the rst-file. For input-cells which are 'hardcoded' in raw/html/markdown it works with nbsphinx - but not for dynamic output.

I've previously used for the tables https://pypi.org/project/tabulate/ but have now switched to https://pypi.org/project/pytablewriter/

For the tables in latex I have currently modified the 'latex' writer in sphinx to have a slightly nicer appearance even with a normal nbsphinx version.

mgeier commented 5 years ago

I've just seen that the sphinxtr project did some tuning for LaTeX tables: https://github.com/jterrace/sphinxtr

Did you have a look at that?

rddaz2013 commented 5 years ago

have my own fork https://github.com/rddaz2013/sphinxtr/tree/UpdatePython27 at that times i still running python2.7! ...with python3 and ipython i moved to your project .-)

I think if a output cell with text/latex would render in raw latex - i will be fine. pytablewirter makes a nice tableoutput