Skip to content

Commit

Permalink
fix list parsing edge case
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vadim-or committed Oct 1, 2023
1 parent 44cc62b commit b950c96
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mistune/list_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
r'(?P<list_3>[ \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:
Expand Down

0 comments on commit b950c96

Please sign in to comment.