From d40ebe29482809fe4c3d0aa4d9a07098c041d448 Mon Sep 17 00:00:00 2001 From: Patrik Dufresne Date: Sat, 26 Jan 2019 15:59:07 -0500 Subject: [PATCH] Make it work with Markdown 2.x and 3.x --- CHANGES.md | 13 +++++++++++++ lektor_pythonmarkdown.py | 9 ++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 CHANGES.md diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..00b7924 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,13 @@ +# Change logs + +## v1.1 + +Release date 26th of January, 2019 + + - Support Markdown v2.x and v3.x + +## v1.0 + +Release date 21th of November, 2018 + + - Initial Release diff --git a/lektor_pythonmarkdown.py b/lektor_pythonmarkdown.py index 3e64500..8acf870 100644 --- a/lektor_pythonmarkdown.py +++ b/lektor_pythonmarkdown.py @@ -6,7 +6,10 @@ Created on Jun 8, 2018 ''' import markdown from markdown.extensions import Extension -from markdown.inlinepatterns import LinkPattern + +# Markdown v3.x +from markdown.inlinepatterns import Pattern + from markupsafe import Markup import types from weakref import ref as weakref @@ -33,7 +36,7 @@ def sanitize_link(self, link): url = url_parse(link) if not url.scheme: link = get_ctx().record.url_to(link, base_url=get_ctx().base_url) - return LinkPattern.sanitize_url(self, link) + return Pattern.unescape(self, link) def sanitize_image(self, link): @@ -44,7 +47,7 @@ def sanitize_image(self, link): url = url_parse(link) if not url.scheme: link = get_ctx().record.url_to(link, alt=PRIMARY_ALT, base_url=get_ctx().base_url) - return LinkPattern.sanitize_url(self, link) + return Pattern.unescape(self, link) class LektorMarkdownExtension(Extension): -- GitLab