diff --git a/tildes/tests/test_markdown.py b/tildes/tests/test_markdown.py index 333110f..3e18196 100644 --- a/tildes/tests/test_markdown.py +++ b/tildes/tests/test_markdown.py @@ -250,7 +250,7 @@ def test_invalid_group_reference_not_linkified(): def test_approximately_tilde_not_linkified(): """Ensure a tilde in front of a number doesn't linkify.""" - markdown = "Mix in ~2 cups of flour and ~1.5 tbsp of sugar." + markdown = "Mix in ~2 cups of flour and ~1.5 tbsp of sugar with ~3kg of meat." processed = convert_markdown_to_safe_html(markdown) assert " - if is_valid_group_path(group_path) and not is_numeric: + # Even though they're technically valid paths, we don't want to linkify anything + # starting with a number like "~10" or "~4.5", since that's just going to be + # someone using it in the "approximately" sense. This will be a problem if a + # top-level group's name ever starts with a number, but I think that's unlikely. + is_ignored = group_path.startswith(tuple("0123456789")) + + # if it's a valid group path and not ignored by the above logic, convert to + if is_valid_group_path(group_path) and not is_ignored: return [ { "type": "StartTag",