68 lines
2.5 KiB
Diff
68 lines
2.5 KiB
Diff
|
From f5f4b297b2cee938e7e13064c7e55ef7c6426bfd Mon Sep 17 00:00:00 2001
|
||
|
From: Neal Gompa <ngompa13@gmail.com>
|
||
|
Date: Wed, 9 Jan 2019 08:39:41 -0500
|
||
|
Subject: [PATCH 2/2] Fix Markdown usage to work with Markdown 3.0+
|
||
|
|
||
|
Markdown 3.0 and later no longer considers the emphasis modifiers
|
||
|
to be an extension, and has them always enabled. We still enable
|
||
|
the 'smart_strong' extension when we detect older versions of
|
||
|
Markdown to retain backward compatibility.
|
||
|
|
||
|
Signed-off-by: Neal Gompa <ngompa13@gmail.com>
|
||
|
---
|
||
|
pagure/lib/query.py | 11 ++++++++++-
|
||
|
tests/test_pagure_lib.py | 7 +++++--
|
||
|
2 files changed, 15 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/pagure/lib/query.py b/pagure/lib/query.py
|
||
|
index 86bda508..ae561196 100644
|
||
|
--- a/pagure/lib/query.py
|
||
|
+++ b/pagure/lib/query.py
|
||
|
@@ -4237,7 +4237,6 @@ def text2markdown(text, extended=True, readme=False):
|
||
|
"markdown.extensions.def_list",
|
||
|
"markdown.extensions.fenced_code",
|
||
|
"markdown.extensions.tables",
|
||
|
- "markdown.extensions.smart_strong",
|
||
|
# All of the above are the .extra extensions
|
||
|
# w/o the "attribute lists" one
|
||
|
"markdown.extensions.admonition",
|
||
|
@@ -4245,6 +4244,16 @@ def text2markdown(text, extended=True, readme=False):
|
||
|
"markdown.extensions.sane_lists",
|
||
|
"markdown.extensions.toc",
|
||
|
]
|
||
|
+
|
||
|
+ # smart_strong is not an extension anymore in markdown 3.0+
|
||
|
+ try:
|
||
|
+ md_version = markdown.__version__.version_info
|
||
|
+ except AttributeError: # pragma: no cover
|
||
|
+ md_version = markdown.__version_info__
|
||
|
+
|
||
|
+ if md_version < (3, 0, 0):
|
||
|
+ extensions.append("markdown.extensions.smart_strong")
|
||
|
+
|
||
|
# Some extensions are enabled for READMEs and disabled otherwise
|
||
|
if readme:
|
||
|
extensions.extend(
|
||
|
diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py
|
||
|
index 50ddab1a..cbb81adc 100644
|
||
|
--- a/tests/test_pagure_lib.py
|
||
|
+++ b/tests/test_pagure_lib.py
|
||
|
@@ -5018,9 +5018,12 @@ class PagureLibtests(tests.Modeltests):
|
||
|
|
||
|
def test_text2markdown_table(self):
|
||
|
""" Test the text2markdown function with a markdown table. """
|
||
|
- v = tuple([int(c) for c in markdown.version.split('.')])
|
||
|
+ try:
|
||
|
+ md_version = markdown.__version__.version_info
|
||
|
+ except AttributeError:
|
||
|
+ md_version = markdown.__version_info__
|
||
|
|
||
|
- if v < (2, 6, 7):
|
||
|
+ if md_version < (2, 6, 7):
|
||
|
raise unittest.case.SkipTest(
|
||
|
'Skipping on old markdown that do not strip the orientation row'
|
||
|
)
|
||
|
--
|
||
|
2.20.1
|
||
|
|