Commit ac2c27be authored by Patrik Dufresne's avatar Patrik Dufresne

Fix link resolution to have similar behavior to default Lektor

Lektor mistune markdown is not doing any link resolution. Let have
similar behavior.
parent 2128bbc6
Pipeline #309 passed with stages
in 1 minute and 14 seconds
......@@ -33,7 +33,7 @@ def sanitize_url(self, link):
if get_ctx() and get_ctx().record is not None:
url = url_parse(link)
if not url.scheme:
link = get_ctx().record.url_to(link,
link = get_ctx().record.url_to("!" + link,
return LinkPattern.sanitize_url(self, link)
......@@ -15,7 +15,7 @@ code here
[Link to Invalid Page](invalid-page)
## Check references
name = demo
name = English
name[fr] = Anglais
locale = en_US
url_prefix = /en/
primary = yes
name = French
name[fr] = Français
url_prefix = /fr/
locale = fr
\ No newline at end of file
......@@ -34,7 +34,7 @@ class TestLektorPythonMarkdown(unittest.TestCase):
def test_basic(self):
failures = self.builder.build_all()
assert not failures
page_path = os.path.join(self.builder.destination_path, 'index.html')
page_path = os.path.join(self.builder.destination_path, 'fr/index.html')
html = open(page_path).read()
assert '<h1 id="header-1">Header 1</h1>' in html
......@@ -42,12 +42,12 @@ class TestLektorPythonMarkdown(unittest.TestCase):
# The output changes depending on the version of python-markdown uses.
# assert '<pre class="codehilite"><code class="linenums">code here</code></pre>' in html
# Check url & image substitution
assert '<a href="./sub-page/">Link to Sub Page</a>' in html
assert '<a href="./slug-url/">Link to Slug</a>' in html
assert '<a href="./invalid-page">Link to Invalid Page</a>' in html
assert '<img alt="alttxt" src="./sub-page/" />' in html
assert '<a href="/fr/sub-page">Link to Sub Page</a>' in html
assert '<a href="/fr/sub-page-slug">Link to Slug</a>' in html
assert '<a href="/fr/invalid-page">Link to Invalid Page</a>' in html
assert '<img alt="alttxt" src="/fr/logo.png" />' in html
# Check references
assert '<a href="./sub-page/" title="Sub Page">Sub Page</a>' in html
assert '<a href="/fr/sub-page/" title="Sub Page">Sub Page</a>' in html
assert '<a href="" title="Yahoo Search">Yahoo</a>' in html
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment