@@ -171,13 +171,13 @@ def get_table_type(self) -> str:
171
171
elif self .has_verbatim :
172
172
return 'tabular'
173
173
elif self .colspec :
174
- assert len ( self . colspec ) > 2
175
- _colspec = re . sub ( r'\{.*?\}' , '' , self . colspec [ 1 : - 2 ])
176
- if any ( c in 'LRCJT' for c in _colspec ):
177
- # tabulary would complain "no suitable columns" if none of its
178
- # column type were used so we ensure at least one matches.
179
- # It is responsability of user to make sure not to use tabulary
180
- # column types for a column containing a problematic cell.
174
+ # tabulary complains (only a LaTeX warning) if none of its column
175
+ # types is used. The next test will have false positive from
176
+ # syntax such as >{\RaggedRight} but it will catch *{3}{J} which
177
+ # does require tabulary and would crash tabular
178
+ # It is user responsability not to use a tabulary column type for
179
+ # a column having a problematic cell.
180
+ if any ( c in 'LRCJT' for c in self . colspec ):
181
181
return 'tabulary'
182
182
else :
183
183
return 'tabular'
@@ -1217,17 +1217,22 @@ def depart_table(self, node: Element) -> None:
1217
1217
# We try to catch a tabularcolumns using L, R, J, C, or T.
1218
1218
# We can not simply test for presence in the colspec of
1219
1219
# one of those letters due to syntax such as >{\RaggedRight}.
1220
+ # The test will not catch *{3}{J} syntax, but it would be
1221
+ # overkill to try to implement LaTeX preamble mini-language.
1220
1222
if self .table .colspec :
1221
1223
assert len (self .table .colspec ) > 2
1222
- _colspec = re .sub (r'\{.*?\}' , '' , self .table .colspec [1 :- 2 ])
1223
- if any (c in _colspec for c in 'LRJCT' ):
1224
+ # cf how self.table.colspec got set in visit_table().
1225
+ _colspec_as_given = self .table .colspec [1 :- 2 ]
1226
+ _colspec_stripped = re .sub (r'\{.*?\}' , '' , _colspec_as_given )
1227
+ if any (c in _colspec_stripped for c in 'LRJCT' ):
1224
1228
logger .warning (
1225
1229
__ (
1226
- 'colspec %s was given which uses '
1230
+ 'colspec %s was given which appears to use '
1227
1231
'tabulary syntax. But this table can not be '
1228
- 'rendered as a tabulary; colspec will be ignored.'
1232
+ 'rendered as a tabulary; the given colspec will '
1233
+ 'be ignored.'
1229
1234
),
1230
- self . table . colspec [: - 1 ] ,
1235
+ _colspec_as_given ,
1231
1236
type = 'latex' ,
1232
1237
location = node ,
1233
1238
)
0 commit comments