Skip to content

Commit

Permalink
Remove optional whitespace from short image markdown (#1290)
Browse files Browse the repository at this point in the history
* Add vim temp files to gitignore

* Remove optional whitespace from short image markdown
  • Loading branch information
AetherUnbound authored and rafalp committed Sep 15, 2019
1 parent 8261457 commit f58fe88
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -50,6 +50,7 @@ pylint.txt
# IDEs
.idea/
.vscode/
*.swp

# Django stuff:
*.log
Expand Down
2 changes: 1 addition & 1 deletion misago/markup/md/shortimgs.py
Expand Up @@ -2,7 +2,7 @@
from markdown.inlinepatterns import LinkPattern
from markdown.util import etree

IMAGES_RE = r"\!(\s?)\((<.*?>|([^\)]*))\)"
IMAGES_RE = r"\!\((<.*?>|([^\)]*))\)"


class ShortImagesExtension(markdown.Extension):
Expand Down
12 changes: 11 additions & 1 deletion misago/markup/tests/snapshots/snap_test_short_image_markdown.py
Expand Up @@ -8,5 +8,15 @@
snapshots = Snapshot()

snapshots[
"test_short_image_markdown 1"
"test_short_image_markdown[base] 1"
] = '<p><img alt="somewhere.com/image.jpg" src="http://somewhere.com/image.jpg"/></p>'
snapshots["test_short_image_markdown[space-one-word] 1"] = "<p>! (space)</p>"
snapshots[
"test_short_image_markdown[space-multiple-words] 1"
] = "<p>! (space with other words)</p>"
snapshots[
"test_short_image_markdown[text-before-mark] 1"
] = '<p>Text before exclamation mark<img alt="somewhere.com/image.jpg" src="http://somewhere.com/image.jpg"/></p>'
snapshots[
"test_short_image_markdown[text-before-with-space] 1"
] = "<p>Text before with space in between! (sometext)</p>"
20 changes: 18 additions & 2 deletions misago/markup/tests/test_short_image_markdown.py
@@ -1,7 +1,23 @@
import pytest

from ..parser import parse


def test_short_image_markdown(request_mock, user, snapshot):
text = "!(http://somewhere.com/image.jpg)"
@pytest.mark.parametrize(
"text",
[
pytest.param("!(http://somewhere.com/image.jpg)", id="base"),
pytest.param("! (space)", id="space-one-word"),
pytest.param("! (space with other words)", id="space-multiple-words"),
pytest.param(
"Text before exclamation mark!(http://somewhere.com/image.jpg)",
id="text-before-mark",
),
pytest.param(
"Text before with space in between! (sometext)", id="text-before-with-space"
),
],
)
def test_short_image_markdown(request_mock, user, snapshot, text):
result = parse(text, request_mock, user, minify=False)
snapshot.assert_match(result["parsed_text"])

0 comments on commit f58fe88

Please sign in to comment.