1717)
1818
1919
20- class VersionNotCompatible (Exception ):
21- pass
22-
23-
2420def markdownify (markdown_text ):
2521 """
2622 Render the markdown content to HTML.
@@ -32,33 +28,25 @@ def markdownify(markdown_text):
3228 '<p><img alt="awesome" src="http://i.imgur.com/hvguiSn.jpg" /></p>'
3329 >>>
3430 """
35- try :
36- # Strip HTML tags
37- markdown_text = strip_tags (markdown_text )
31+ # Strip HTML tags
32+ markdown_text = strip_tags (markdown_text )
3833
39- # Sanitize Markdown links
40- # https://github.com/netbox-community/netbox/commit/5af2b3c2f577a01d177cb24cda1019551a2a4b64
41- schemes = "|" .join (ALLOWED_URL_SCHEMES )
42- pattern = fr"\[(.+)\]\((?!({ schemes } )).*:(.+)\)"
43- markdown_text = re .sub (
44- pattern ,
45- "[\\ 1](\\ 3)" ,
46- markdown_text ,
47- flags = re .IGNORECASE ,
48- )
34+ # Sanitize Markdown links
35+ # https://github.com/netbox-community/netbox/commit/5af2b3c2f577a01d177cb24cda1019551a2a4b64
36+ schemes = "|" .join (ALLOWED_URL_SCHEMES )
37+ pattern = fr"\[(.+)\]\((?!({ schemes } )).*:(.+)\)"
38+ markdown_text = re .sub (
39+ pattern ,
40+ "[\\ 1](\\ 3)" ,
41+ markdown_text ,
42+ flags = re .IGNORECASE ,
43+ )
4944
50- return markdown .markdown (
51- markdown_text ,
52- extensions = MARTOR_MARKDOWN_EXTENSIONS ,
53- extension_configs = MARTOR_MARKDOWN_EXTENSION_CONFIGS ,
54- )
55- except TypeError as e :
56- if "extendMarkdown" not in str (e ):
57- raise
58- raise VersionNotCompatible (
59- "The markdown isn't compatible, please reinstall "
60- "your python markdown into Markdown>=3.0"
61- )
45+ return markdown .markdown (
46+ markdown_text ,
47+ extensions = MARTOR_MARKDOWN_EXTENSIONS ,
48+ extension_configs = MARTOR_MARKDOWN_EXTENSION_CONFIGS ,
49+ )
6250
6351
6452class LazyEncoder (DjangoJSONEncoder ):
0 commit comments