diff --git a/.gitignore b/.gitignore index 2e5dd37ae75f3ab092721f9610291f52a49000aa..e1f3282894d246d1045e0cc5e896c77bfe5fd5f1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build .cache /.project /.pydevproject +/.eggs/ diff --git a/lektor_pythonmarkdown.py b/lektor_pythonmarkdown.py index 93409cc444f53c1ff536a19a5cd2a3cddd5ab695..ddec0b21509f2578a7e1693476c0feccd1ea8213 100644 --- a/lektor_pythonmarkdown.py +++ b/lektor_pythonmarkdown.py @@ -32,7 +32,7 @@ def sanitize_url(self, link): try: url = url_parse(link) if not url.scheme: - link = url_to("!" + link) + link = url_to(link) except: # Do not fail if something went wrong during the url parsing. pass diff --git a/tests/demo-project/content/contents.lr b/tests/demo-project/content/contents.lr index 384d5d8bcd158c54f8ec1791e23989ff3d58118a..8f5c1aac048261f68e50deb2f5fbb4d0f8bc0375 100644 --- a/tests/demo-project/content/contents.lr +++ b/tests/demo-project/content/contents.lr @@ -11,6 +11,9 @@ code here ## Check url & image substitution [Link to Sub Page](sub-page) +[Link to Slug](sub-page-slug) +[Link to Invalid Page](invalid-page) + ![alttxt](sub-page) diff --git a/tests/demo-project/content/sub-page-slug/contents.lr b/tests/demo-project/content/sub-page-slug/contents.lr new file mode 100644 index 0000000000000000000000000000000000000000..101e2bf42ead7db676bb27ebb1bc98bd8613805a --- /dev/null +++ b/tests/demo-project/content/sub-page-slug/contents.lr @@ -0,0 +1,5 @@ +_slug: slug-url +--- +body: + +Nothing special \ No newline at end of file diff --git a/tests/test_lektor_pythonmarkdown.py b/tests/test_lektor_pythonmarkdown.py index 4b7a3f29853ed945bfcbbc74e0819901a9e17e36..84f6e5d671a6ec38f94a74707b977e9c08fca14a 100644 --- a/tests/test_lektor_pythonmarkdown.py +++ b/tests/test_lektor_pythonmarkdown.py @@ -40,10 +40,12 @@ class TestLektorPythonMarkdown(unittest.TestCase): assert '

Header 1

' in html assert '

Header 2

' in html # The output changes depending on the version of python-markdown uses. - assert '
code here
' in html + # assert '
code here
' in html # Check url & image substitution - assert 'Link to Sub Page' in html - assert 'alttxt' in html + assert 'Link to Sub Page' in html + assert 'Link to Slug' in html + assert 'Link to Invalid Page' in html + assert 'alttxt' in html # Check references assert 'Sub Page' in html assert 'Yahoo' in html