Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/pydata_sphinx_theme/assets/styles/content/_tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ td {
--pst-color-text-base
); // ensure text and bullets are visible
}

.pst-scrollable-table-container {
// Put a scrollbar just below tables that are too wide to fit within the main
// column
overflow-x: auto;
}
8 changes: 8 additions & 0 deletions src/pydata_sphinx_theme/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,17 @@ def visit_table(self, node):
if "align" in node:
classes.append(f'table-{node["align"]}')

# put table within a scrollable container (for tables that are too wide)
self.body.append('<div class="pst-scrollable-table-container">')

tag = self.starttag(node, "table", CLASS=" ".join(classes), **atts)
self.body.append(tag)

def depart_table(self, node):
"""Custom depart_table method to close the scrollable div we add in visit_table."""
super().depart_table(node)
self.body.append("</div>\n")


def setup_translators(app: Sphinx):
"""Add bootstrap HTML functionality if we are using an HTML translator.
Expand Down