From b950c966cbb692924a089c859cc96727c5cb3e97 Mon Sep 17 00:00:00 2001 From: Vadim Suvorov Date: Sun, 1 Oct 2023 15:37:13 -0700 Subject: [PATCH] fix list parsing edge case fix an incorrect list parsing (text dropped) in situations like: ``` 1. item 1 2. \xA0 item 2 ``` The line text is dropped because first non-space sharacter happens to match `\s` regex pattern. There are alternative fixes: * change regex to `( *)[^ ]`. * use `text.isspace()` and `text.lstrip()` instead of regex matching. --- src/mistune/list_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mistune/list_parser.py b/src/mistune/list_parser.py index 6ce6baa..bac4168 100644 --- a/src/mistune/list_parser.py +++ b/src/mistune/list_parser.py @@ -13,7 +13,7 @@ r'(?P[ \t]*|[ \t].+)$' ) -_LINE_HAS_TEXT = re.compile(r'( *)\S') +_LINE_HAS_TEXT = re.compile(r'(\s*)\S') def parse_list(block, m: re.Match, state: BlockState) -> int: