From 50d452496d938aa9afd49e5f37f098a551ffe287 Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 31 Jul 2019 18:05:43 -0600 Subject: [PATCH] Markdown: require double tildes for strikethrough Previously, either double or single tildes would work for strikethrough. However, this had some strange edge cases, such as attempting to strikethrough some words that contain a group reference. Since Tildes uses single tildes for other purposes, it should be much less ambiguous overall to just force double tildes for strikethrough like this. This will affect a small number of past posts, in both good and bad ways (getting rid of some strikethrough, but fixing some accidental ones). --- tildes/tests/test_markdown.py | 21 +++++++++++++++++++-- tildes/tildes/lib/cmark.py | 13 ++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/tildes/tests/test_markdown.py b/tildes/tests/test_markdown.py index e11d8b3..c56951b 100644 --- a/tildes/tests/test_markdown.py +++ b/tildes/tests/test_markdown.py @@ -36,13 +36,30 @@ def test_basic_markdown_unescaped(): def test_strikethrough(): """Ensure strikethrough works and doesn't turn into a group link.""" - markdown = "This ~should not~ should work" + markdown = "This ~~should not~~ should work" processed = convert_markdown_to_safe_html(markdown) assert "" in processed assert "" not in processed + + +def test_strikethrough_with_group(): + """Ensure strikethrough works with a group name in the middle.""" + markdown = "They ~~spammed ~music heavily~~ posted lots of songs." + processed = convert_markdown_to_safe_html(markdown) + + assert processed.count("") == 1 + assert " tag doesn't get linked.""" - markdown = "Strikethrough works like: `this ~should not~ work`." + markdown = "Link to a group by just writing its name: `see ~news for more`." processed = convert_markdown_to_safe_html(markdown) assert "