File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,10 @@ Configuration Options
103
103
``table_classes ``
104
104
A list of classes to **not strip ** from tables. All other classes are stripped, and the default
105
105
table has no class attribute. Custom table classes need to provide the full style for the table.
106
-
106
+ ``table_no_strip ``
107
+ A list of classes to deactivate the complete table handling by sphinx-material for this specific table,
108
+ so that all set table classes are kept.
109
+ Default value: ``no-sphinx-material-strip ``.
107
110
Sidebars
108
111
========
109
112
Original file line number Diff line number Diff line change 22
22
ROOT_SUFFIX = "--page-root"
23
23
24
24
USER_TABLE_CLASSES = []
25
+ USER_TABLE_NO_STRIP_CLASSES = ["no-sphinx-material-strip" ]
25
26
26
27
27
28
def setup (app ):
@@ -150,6 +151,10 @@ def update_table_classes(app, config):
150
151
if table_classes :
151
152
USER_TABLE_CLASSES .extend (table_classes )
152
153
154
+ table_no_strip_classes = config .html_theme_options .get ("table_no_strip" )
155
+ if table_no_strip_classes :
156
+ USER_TABLE_NO_STRIP_CLASSES .extend (table_no_strip_classes )
157
+
153
158
154
159
def html_theme_path ():
155
160
return [os .path .dirname (os .path .abspath (__file__ ))]
@@ -228,7 +233,9 @@ def walk_contents(tags):
228
233
229
234
def table_fix (body_text , page_name = "md-page-root--link" ):
230
235
# This is a hack to skip certain classes of tables
231
- ignore_table_classes = {"highlighttable" , "longtable" , "dataframe" }
236
+ ignore_table_classes = {"highlighttable" , "longtable" , "dataframe" } | set (
237
+ USER_TABLE_NO_STRIP_CLASSES
238
+ )
232
239
try :
233
240
body = BeautifulSoup (body_text , features = "html.parser" )
234
241
for table in body .select ("table" ):
Original file line number Diff line number Diff line change @@ -109,4 +109,9 @@ version_json = "versions.json"
109
109
# Table classes to _not_ strip. Must be a list. Classes on this list are *not*
110
110
# removed from tables. All other classes are removed, and only tables with outclasses
111
111
# are styled by default.
112
- table_classes =
112
+ table_classes =
113
+
114
+ # Table classes, which deactivates the overall class striping. If one of the configured
115
+ # classes is set, **all** table classes are kept.
116
+ # This is different to "table_classes", which only keeps the configured classes.
117
+ table_no_strip =
You can’t perform that action at this time.
0 commit comments