markup.txt 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. =====================
  2. django.contrib.markup
  3. =====================
  4. .. module:: django.contrib.markup
  5. :synopsis: A collection of template filters that implement common markup languages.
  6. .. deprecated:: 1.5
  7. This module has been deprecated.
  8. Django provides template filters that implement the following markup
  9. languages:
  10. * ``textile`` -- implements `Textile`_ -- requires `PyTextile`_
  11. * ``markdown`` -- implements `Markdown`_ -- requires `Python-markdown`_ (>=2.1)
  12. * ``restructuredtext`` -- implements `reST (reStructured Text)`_
  13. -- requires `doc-utils`_
  14. In each case, the filter expects formatted markup as a string and
  15. returns a string representing the marked-up text. For example, the
  16. ``textile`` filter converts text that is marked-up in Textile format
  17. to HTML.
  18. To activate these filters, add ``'django.contrib.markup'`` to your
  19. :setting:`INSTALLED_APPS` setting. Once you've done that, use
  20. ``{% load markup %}`` in a template, and you'll have access to these filters.
  21. For more documentation, read the source code in
  22. :file:`django/contrib/markup/templatetags/markup.py`.
  23. .. warning::
  24. The output of markup filters is marked "safe" and will not be escaped when
  25. rendered in a template. Always be careful to sanitize your inputs and make
  26. sure you are not leaving yourself vulnerable to cross-site scripting or
  27. other types of attacks.
  28. .. _Textile: http://en.wikipedia.org/wiki/Textile_%28markup_language%29
  29. .. _Markdown: http://en.wikipedia.org/wiki/Markdown
  30. .. _reST (reStructured Text): http://en.wikipedia.org/wiki/ReStructuredText
  31. .. _PyTextile: http://loopcore.com/python-textile/
  32. .. _Python-markdown: http://pypi.python.org/pypi/Markdown
  33. .. _doc-utils: http://docutils.sf.net/
  34. reStructured Text
  35. -----------------
  36. When using the ``restructuredtext`` markup filter you can define a
  37. :setting:`RESTRUCTUREDTEXT_FILTER_SETTINGS` in your django settings to
  38. override the default writer settings. See the `restructuredtext writer
  39. settings`_ for details on what these settings are.
  40. .. warning::
  41. reStructured Text has features that allow raw HTML to be included, and that
  42. allow arbitrary files to be included. These can lead to XSS vulnerabilities
  43. and leaking of private information. It is your responsibility to check the
  44. features of this library and configure appropriately to avoid this. See the
  45. `Deploying Docutils Securely
  46. <http://docutils.sourceforge.net/docs/howto/security.html>`_ documentation.
  47. .. _restructuredtext writer settings: http://docutils.sourceforge.net/docs/user/config.html#html4css1-writer
  48. Markdown
  49. --------
  50. The Python Markdown library supports options named "safe_mode" and
  51. "enable_attributes". Both relate to the security of the output. To enable both
  52. options in tandem, the markdown filter supports the "safe" argument::
  53. {{ markdown_content_var|markdown:"safe" }}
  54. .. warning::
  55. Versions of the Python-Markdown library prior to 2.1 do not support the
  56. optional disabling of attributes. This is a security flaw. Therefore,
  57. ``django.contrib.markup`` has dropped support for versions of
  58. Python-Markdown < 2.1 in Django 1.5.