@@ -250,13 +250,10 @@ def accept_verbatim(verbatim)
250250 # Adds +table+ to the output
251251
252252 def accept_table ( header , body , aligns )
253- body = body . map do |row |
254- row . map do |cell |
255- attributes cell
256- end
257- end
253+ header = header . map { |h | attributes h }
254+ body = body . map { |row | row . map { |t | attributes t } }
258255 widths = header . zip ( *body ) . map do |cols |
259- cols . map ( & :size ) . max
256+ cols . map { | col | calculate_text_width ( col ) } . max
260257 end
261258 aligns = aligns . map do |a |
262259 case a
@@ -269,16 +266,22 @@ def accept_table(header, body, aligns)
269266 end
270267 end
271268 @res << header . zip ( widths , aligns ) . map do |h , w , a |
272- h . __send__ ( a , w )
269+ extra_width = h . size - calculate_text_width ( h )
270+ h . __send__ ( a , w + extra_width )
273271 end . join ( "|" ) . rstrip << "\n "
274272 @res << widths . map { |w | "-" * w } . join ( "|" ) << "\n "
275273 body . each do |row |
276274 @res << row . zip ( widths , aligns ) . map do |t , w , a |
277- t . __send__ ( a , w )
275+ extra_width = t . size - calculate_text_width ( t )
276+ t . __send__ ( a , w + extra_width )
278277 end . join ( "|" ) . rstrip << "\n "
279278 end
280279 end
281280
281+ def calculate_text_width ( text )
282+ text . size
283+ end
284+
282285 ##
283286 # Applies attribute-specific markup to +text+ using RDoc::AttributeManager
284287
0 commit comments