开源软件名称(OpenSource Name):erwinmatijsen/django-markdownify开源软件地址(OpenSource Url):https://github.com/erwinmatijsen/django-markdownify开源编程语言(OpenSource Language):Python 100.0%开源软件介绍(OpenSource Introduction):Django Markdownify - A Django Markdown filterDjango Markdownify is a template filter to convert Markdown to HTML in Django. Markdown is converted to HTML and sanitized. Read the full documentation on Read the docs or check out the package on pypi. UsageLoad the tag inside your template:
Then you can change markdown to html as follows:
or
Example
Is transformed to: <p>
Some <em>test</em> <a href="#">link</a>
</p> The filter is a wrapper around Markdown and Bleach and as such supports their settings. It is possible to define multiple settings for multiple usecases. For example: # settings.py
MARKDOWNIFY = {
"default": {
"WHITELIST_TAGS": ["a", "p", "h1", ]
},
"alternative": {
"WHITELIST_TAGS": ["a", "p", ],
"MARKDOWN_EXTENSIONS": ["markdown.extensions.fenced_code", ]
}
} And in your templates: <!-- page1.html -->
{{ mytext|markdownify }} <!-- Uses your default settings -->
<!-- page2.html -->
{{ mytext|markdownify:"alternative" }} <!-- Uses your alternative settings --> DocumentationRead the full documentation on Read the docs. CreditsThis filter is a slightly richer and packaged version of the snippet: using-markdown-django-17. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论