Ticket #17714: 17714_markdown_extensions_multiple_options.diff
File 17714_markdown_extensions_multiple_options.diff, 1.6 KB (added by , 13 years ago) |
---|
-
django/contrib/markup/templatetags/markup.py
43 43 generated by actual Markdown syntax, pass "safe" as the first 44 44 extension in the list. 45 45 46 Extensions may be given configuration options in the form of key=value 47 pairs, separated by commas and enclosed in parenthesis immediately after 48 the extension name. For example: 49 50 {{ value|markdown:"ext_name(key1=val1, key2=val2),ext2,ext3,..." }} 51 46 52 If the version of Markdown in use does not support extensions, 47 53 they will be silently ignored. 48 54 … … 57 63 # markdown.version was first added in 1.6b. The only version of markdown 58 64 # to fully support extensions before 1.6b was the shortlived 1.6a. 59 65 if hasattr(markdown, 'version'): 60 extensions = [e for e in arg.split(",") if e] 66 extensions = [] 67 # Ensure that splitting into extensions by commas ignores those 68 # commas contained within parenthesis, so that extensions are 69 # allowed multiple configuration options. 70 for part in arg.split("("): 71 if ")" in part and extensions: 72 config, part = part.split(")") 73 extensions[-1] += "(%s)" % config 74 extensions.extend(e for e in part.split(",") if e) 75 61 76 if len(extensions) > 0 and extensions[0] == "safe": 62 77 extensions = extensions[1:] 63 78 safe_mode = True