diff --git a/CHANGES.md b/CHANGES.md index 1798e3d5..26cde7b0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ - [pull #623] Don't escape plus signs in URLs (#621) - [pull #626] Fix XSS when encoding incomplete tags (#625) - [pull #628] Fix TypeError in MiddleWordEm extra when options was None (#627) +- [pull #630] Fix nbsp breaking tables (#629) ## python-markdown2 2.5.3 diff --git a/lib/markdown2.py b/lib/markdown2.py index 19cfca61..265bb7d1 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -3576,7 +3576,7 @@ def run(self, text): return table_re.sub(self.sub, text) def sub(self, match: re.Match) -> str: - trim_space_re = '^[ \t\n]+|[ \t\n]+$' + trim_space_re = r'^\s+|\s+$' trim_bar_re = r'^\||\|$' split_bar_re = r'^\||(? + + + A + B + + + + + Foo + 123 + + + diff --git a/test/tm-cases/tables_nbsp_issue629.opts b/test/tm-cases/tables_nbsp_issue629.opts new file mode 100644 index 00000000..0fe946d7 --- /dev/null +++ b/test/tm-cases/tables_nbsp_issue629.opts @@ -0,0 +1 @@ +{'extras': ['tables']} \ No newline at end of file diff --git a/test/tm-cases/tables_nbsp_issue629.text b/test/tm-cases/tables_nbsp_issue629.text new file mode 100644 index 00000000..56aaad75 --- /dev/null +++ b/test/tm-cases/tables_nbsp_issue629.text @@ -0,0 +1,3 @@ +| A | B | +|-----|-----|  +| Foo | 123 | \ No newline at end of file