File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 21
21
from markupfield .markup import DEFAULT_MARKUP_TYPES
22
22
23
23
import cmarkgfm
24
+ from cmarkgfm .cmark import Options as cmarkgfmOptions
24
25
25
26
from cms .models import ContentManageable
26
27
from fastly .utils import purge_url
29
30
30
31
DEFAULT_MARKUP_TYPE = getattr (settings , 'DEFAULT_MARKUP_TYPE' , 'restructuredtext' )
31
32
33
+ # Set options for cmarkgfm for "unsafe" renderer, see https://github.com/theacodes/cmarkgfm#advanced-usage
34
+ CMARKGFM_UNSAFE_OPTIONS = (
35
+ cmarkgfmOptions .CMARK_OPT_UNSAFE
36
+ )
37
+
32
38
PAGE_PATH_RE = re .compile (r"""
33
39
^
34
40
/? # We can optionally start with a /
59
65
'Markdown'
60
66
)
61
67
68
+ RENDERERS .append (
69
+ (
70
+ "markdown_unsafe" ,
71
+ lambda markdown_text : cmarkgfm .github_flavored_markdown_to_html (markdown_text , options = CMARKGFM_UNSAFE_OPTIONS ),
72
+ "Markdown (unsafe)" ,
73
+ )
74
+ )
75
+
62
76
63
77
class Page (ContentManageable ):
64
78
title = models .CharField (max_length = 500 )
You can’t perform that action at this time.
0 commit comments