Commit 2128bbc6 authored by Patrik Dufresne's avatar Patrik Dufresne

Fix link resolution by making use of context

parent 8d373c07
Pipeline #305 passed with stages
in 1 minute and 14 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
SECTION_EXTENSIONS = "extensions"
SECTION_MARKDOWN = "markdown"
DEFAULT_EXTENTIONS = {
......@@ -29,13 +30,11 @@ def sanitize_url(self, link):
"""
Patched function to resolve the url using Lektor.
"""
try:
if get_ctx() and get_ctx().record is not None:
url = url_parse(link)
if not url.scheme:
link = url_to(link)
except:
# Do not fail if something went wrong during the url parsing.
pass
link = get_ctx().record.url_to(link,
base_url=get_ctx().base_url)
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