Commit 7f290bf9 authored by Patrik Dufresne's avatar Patrik Dufresne

Merge branch 'develop/fix-link' into 'master'

Fix link resolution by making use of context

See merge request !5
parents 221e0fe1 2128bbc6
Pipeline #307 passed with stages
in 1 minute and 16 seconds
......@@ -10,7 +10,7 @@ from markdown.inlinepatterns import LinkPattern
import types
from weakref import ref as weakref
from lektor.context import get_ctx, url_to
from lektor.context import get_ctx
from lektor.pluginsystem import Plugin
from lektor.types import Type
from lektor.utils import bool_from_string
......@@ -18,6 +18,7 @@ from markupsafe import Markup
from werkzeug.urls import url_parse
......@@ -29,13 +30,11 @@ def sanitize_url(self, link):
Patched function to resolve the url using Lektor.
if get_ctx() and get_ctx().record is not None:
url = url_parse(link)
if not url.scheme:
link = url_to(link)
# Do not fail if something went wrong during the url parsing.
link = get_ctx().record.url_to(link,
return LinkPattern.sanitize_url(self, link)
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