@@ -90,6 +90,9 @@ def _trim_line(
9090 def get_lines_content (self , start : Cursor , end : Cursor ) -> list [str ]:
9191 # TODO ... this is an off-by 1 error nightmare ...
9292 # Some unit testing might be really worth it ...
93+ if start == end :
94+ return []
95+
9396 if start .line == end .line :
9497 return [self ._trim_line (self .lines [start .line ], start = start , end = end )]
9598
@@ -311,7 +314,6 @@ def _into_output_lines_cell(self, file_content: FileContent) -> list[str]:
311314 if isinstance (self .end , UnknownEnd ):
312315 raise ValueError (f"BlockContext { self } has no end" )
313316 out = []
314- out .append ("\n \n " )
315317 last_end = self .start .advance_line (1 )
316318 tmp = self .find_inner_block (file_content , context = [], start = last_end )
317319 while tmp is not None :
@@ -323,7 +325,6 @@ def _into_output_lines_cell(self, file_content: FileContent) -> list[str]:
323325 tmp = self .find_inner_block (file_content , context = [], start = last_end )
324326
325327 out .extend (file_content .get_lines_content (last_end , self .end .advance_line (- 1 )))
326- out .append ("\n \n " )
327328
328329 return out
329330
@@ -341,7 +342,7 @@ def _into_output_lines_cell_elem(self, file_content: FileContent) -> list[str]:
341342 )
342343
343344 out .append (admon_candidates [0 ])
344- out .append ("\n " )
345+ out .append ("" )
345346
346347 internal = []
347348 last_end = self .start .advance_line (1 )
@@ -376,7 +377,7 @@ def _into_output_lines_cell_elem(self, file_content: FileContent) -> list[str]:
376377 file_content .get_lines_content (last_end , self .end .advance_line (0 ))
377378 )
378379 out .extend ([" " * 4 + line for line in internal ])
379- out .append ("\n \n " )
380+ out .append ("" )
380381
381382 return out
382383
@@ -387,7 +388,6 @@ def _into_output_lines_codeblock(
387388 if isinstance (self .end , UnknownEnd ):
388389 raise ValueError (f"BlockContext { self } has no end" )
389390 out = []
390- out .append ("\n \n " )
391391 language = ""
392392 if self .attributes :
393393 language = self .attributes [0 ]
@@ -403,7 +403,6 @@ def _into_output_lines_codeblock(
403403
404404 out .extend (file_content .get_lines_content (last_end , self .end .advance_line (0 )))
405405 out .append (f"{ self .delimiter } " )
406- out .append ("\n \n " )
407406 return out
408407
409408
0 commit comments