File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,7 +138,11 @@ def list_of_dicts_to_markdown_table(
138138 if max_length is None or len (full_table ) <= max_length :
139139 return full_table
140140
141+ if max_length <= 0 :
142+ return ""
141143 truncation_note = "\n (truncated)"
144+ if max_length <= len (truncation_note ):
145+ return "(truncated)" [:max_length ]
142146 effective_max = max_length - len (truncation_note )
143147 for row_count in range (len (processed_data ) - 1 , 0 , - 1 ):
144148 table = tabulate (
@@ -156,6 +160,6 @@ def list_of_dicts_to_markdown_table(
156160 tablefmt = "github" ,
157161 disable_numparse = True ,
158162 )
159- if effective_max <= 0 or len (single_row_table ) <= effective_max :
163+ if len (single_row_table ) <= effective_max :
160164 return single_row_table + truncation_note
161165 return single_row_table [:effective_max ].rstrip () + truncation_note
You can’t perform that action at this time.
0 commit comments