@@ -152,7 +152,7 @@ def handle_non_fenced_code_section(
152152
153153 # pylint: enable=too-many-arguments, too-many-locals
154154
155- # pylint: disable=too-many-arguments
155+ # pylint: disable=too-many-arguments,too-many-locals
156156 @staticmethod
157157 def __handle_non_fenced_code_section_no_requeue (
158158 parser_state : ParserState ,
@@ -182,6 +182,7 @@ def __handle_non_fenced_code_section_no_requeue(
182182 found_bq_stack_token = cast (
183183 BlockQuoteStackToken , parser_state .token_stack [stack_index ]
184184 )
185+ is_not_blank_line = bool (line_to_parse .strip (Constants .ascii_whitespace ))
185186
186187 BlockQuoteNonFencedHelper .__do_block_quote_leading_spaces_adjustments (
187188 parser_state ,
@@ -195,10 +196,12 @@ def __handle_non_fenced_code_section_no_requeue(
195196 extra_consumed_whitespace ,
196197 container_level_tokens ,
197198 original_line ,
199+ is_not_blank_line ,
200+ position_marker ,
198201 )
199202 POGGER .debug ("text_removed_by_container=[$]" , removed_text )
200203 POGGER .debug ("removed_text=[$]" , removed_text )
201- if line_to_parse . strip ( Constants . ascii_whitespace ) :
204+ if is_not_blank_line :
202205 return (
203206 line_to_parse ,
204207 start_index ,
@@ -221,9 +224,9 @@ def __handle_non_fenced_code_section_no_requeue(
221224 leaf_tokens ,
222225 )
223226
224- # pylint: enable=too-many-arguments
227+ # pylint: enable=too-many-arguments,too-many-locals
225228
226- # pylint: disable=too-many-arguments
229+ # pylint: disable=too-many-arguments,too-many-locals
227230 @staticmethod
228231 def __do_block_quote_leading_spaces_adjustments (
229232 parser_state : ParserState ,
@@ -237,6 +240,8 @@ def __do_block_quote_leading_spaces_adjustments(
237240 extra_consumed_whitespace : Optional [int ],
238241 container_level_tokens : List [MarkdownToken ],
239242 original_line : str ,
243+ is_not_blank_line : bool ,
244+ position_marker : PositionMarker ,
240245 ) -> None :
241246 POGGER .debug ("__hbqs>>removed_text>>:$:<" , removed_text )
242247 POGGER .debug ("__hbqs>>container_start_bq_count>>$" , container_start_bq_count )
@@ -287,13 +292,17 @@ def __do_block_quote_leading_spaces_adjustments(
287292 POGGER .debug ("dbqlsa>>special_case>>$" , special_case )
288293
289294 BlockQuoteNonFencedHelper .__do_block_quote_leading_spaces_adjustments_adjust_bleading (
295+ parser_state ,
290296 found_bq_stack_token ,
291297 tabbed_removed_text ,
292298 adjusted_removed_text ,
293299 special_case ,
300+ is_not_blank_line ,
301+ stack_index ,
302+ position_marker ,
294303 )
295304
296- # pylint: enable=too-many-arguments
305+ # pylint: enable=too-many-arguments,too-many-locals
297306
298307 @staticmethod
299308 def __handle_normal_blank_line (
@@ -329,18 +338,6 @@ def __handle_normal_blank_line(
329338 requeue_line_info and requeue_line_info .lines_to_requeue
330339 ), "No handling of requeuing available here."
331340
332- # KLUDGE!
333- if (
334- len (parser_state .token_stack ) == 3
335- and parser_state .token_stack [1 ].is_list
336- and parser_state .token_stack [2 ].is_block_quote
337- ):
338- list_token = cast (
339- ListStartMarkdownToken ,
340- parser_state .token_stack [1 ].matching_markdown_token ,
341- )
342- list_token .add_leading_spaces ("" )
343-
344341 return True , leaf_tokens
345342
346343 # pylint: disable=too-many-arguments
@@ -491,12 +488,17 @@ def __block_quote_start_adjust(
491488 original_start_index -= indent_delta
492489 return original_start_index
493490
491+ # pylint: disable=too-many-arguments
494492 @staticmethod
495493 def __do_block_quote_leading_spaces_adjustments_adjust_bleading (
494+ parser_state : ParserState ,
496495 found_bq_stack_token : BlockQuoteStackToken ,
497496 tabbed_removed_text : Optional [str ],
498497 adjusted_removed_text : str ,
499498 special_case : bool ,
499+ is_not_blank_line : bool ,
500+ stack_index : int ,
501+ position_marker : PositionMarker ,
500502 ) -> None :
501503 assert (
502504 found_bq_stack_token .matching_markdown_token is not None
@@ -521,9 +523,29 @@ def __do_block_quote_leading_spaces_adjustments_adjust_bleading(
521523 POGGER .debug (
522524 "dbqlsa>>leading_text_index>>$" , block_quote_token .leading_text_index
523525 )
526+ if not is_not_blank_line :
527+ assert parser_state .token_stack [stack_index ] == found_bq_stack_token
528+ found_list_stack_index = 0
529+ for search_index in range (stack_index , 0 , - 1 ):
530+ if (
531+ parser_state .token_stack [search_index ].is_list
532+ and not found_list_stack_index
533+ ):
534+ found_list_stack_index = search_index
535+ if found_list_stack_index :
536+ list_token = cast (
537+ ListStartMarkdownToken ,
538+ parser_state .token_stack [
539+ found_list_stack_index
540+ ].matching_markdown_token ,
541+ )
542+ if position_marker .line_number != list_token .line_number :
543+ list_token .add_leading_spaces ("" )
524544
525545 POGGER .debug ("__hbqs>>bq>>$" , block_quote_token )
526546
547+ # pylint: enable=too-many-arguments
548+
527549 # pylint: disable=too-many-arguments
528550 @staticmethod
529551 def __adjust_2 (
0 commit comments