Enable autolinking and a bunch of other handy Markdown features

This commit is contained in:
Danielle McLean 2017-10-26 09:23:51 +11:00
parent f39782346f
commit c4f7ea7fc6
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

View file

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/1.11/ref/settings/
""" """
import os import os
import re
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@ -216,16 +217,42 @@ def copy_update(source_dict, **kwargs):
return copy return copy
link_patterns = [(re.compile(pat), rep) for (pat, rep) in (
# autolink actual URLs in text
(
r'((([A-Za-z]{3,9}:(?:\/\/)?)' + # scheme
r'(?:[\-;:&=\+\$,\w]+@)?' + # basic auth
r'[A-Za-z0-9\.\-]+(:[0-9]+)?' + # ip address
r'|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)' + # or hostname
r'((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)' + # path
r'#?(?:[\.\!\/\\\w]*))?)', # hash
r'\1'
),
)]
MARKDOWN_DEUX_DEFAULT_STYLE = { MARKDOWN_DEUX_DEFAULT_STYLE = {
"extras": { 'extras': (
"code-friendly": None, 'code-friendly',
}, 'cuddled-lists',
"safe_mode": "escape", 'fenced-code-blocks',
'footnotes',
'header-ids',
'link-patterns',
'spoiler',
'tag-friendly',
),
'link_patterns': link_patterns,
'safe_mode': 'escape',
} }
MARKDOWN_DEUX_STYLES = { MARKDOWN_DEUX_STYLES = {
'default': MARKDOWN_DEUX_DEFAULT_STYLE, 'default': MARKDOWN_DEUX_DEFAULT_STYLE,
'trusted': copy_update(MARKDOWN_DEUX_DEFAULT_STYLE, safe_mode=False), 'trusted': copy_update(
MARKDOWN_DEUX_DEFAULT_STYLE,
link_patterns=[],
safe_mode=False,
),
} }
# django-meta # django-meta