Skip to content

ENH Add CSS for pandas dataframe #544

@lucyleeow

Description

@lucyleeow

With #541, Sphinx-Gallery can capture raw HTML (using the _repr_html_() of an object) and embed in rst. In some cases, where the captured raw HTML does not include CSS (e.g. pandas dataframes), this can be added to make the output look better. For reference this (scroll down) is what a pandas dataframe looks like with just the raw HTML.

For example, Jupyter notebook seems to take CSS from their own renderedhtml.less (see @larsoner's post). For reference this SO question describes how to get pandas dataframes to look like those in Jupyter notebook.

One solution is that we can include our own CSS for common objects like pandas dataframes (I think this might be beyond the scope of SG).

Another solution is to obtain CSS from the objects we capture _repr_html_ from, if possible.

Another solution would be to add a add_css configuration to allow the user add their own CSS file (e.g. pandas dataframes have specific HTML tags that can be used to write CSS specifically for dataframes), a reference to which would be added at the end of raw HTML embedded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions