markup.txt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. =====================
  2. django.contrib.markup
  3. =====================
  4. .. module:: django.contrib.markup
  5. :synopsis: A collection of template filters that implement common markup languages.
  6. Django provides template filters that implement the following markup
  7. languages:
  8. * ``textile`` -- implements `Textile`_ -- requires `PyTextile`_
  9. * ``markdown`` -- implements `Markdown`_ -- requires `Python-markdown`_
  10. * ``restructuredtext`` -- implements `reST (reStructured Text)`_
  11. -- requires `doc-utils`_
  12. In each case, the filter expects formatted markup as a string and
  13. returns a string representing the marked-up text. For example, the
  14. ``textile`` filter converts text that is marked-up in Textile format
  15. to HTML.
  16. To activate these filters, add ``'django.contrib.markup'`` to your
  17. :setting:`INSTALLED_APPS` setting. Once you've done that, use
  18. ``{% load markup %}`` in a template, and you'll have access to these filters.
  19. For more documentation, read the source code in
  20. :file:`django/contrib/markup/templatetags/markup.py`.
  21. .. warning::
  22. The output of markup filters is marked "safe" and will not be escaped when
  23. rendered in a template. Always be careful to sanitize your inputs and make
  24. sure you are not leaving yourself vulnerable to cross-site scripting or
  25. other types of attacks.
  26. .. _Textile: http://en.wikipedia.org/wiki/Textile_%28markup_language%29
  27. .. _Markdown: http://en.wikipedia.org/wiki/Markdown
  28. .. _reST (reStructured Text): http://en.wikipedia.org/wiki/ReStructuredText
  29. .. _PyTextile: http://loopcore.com/python-textile/
  30. .. _Python-markdown: http://www.freewisdom.org/projects/python-markdown
  31. .. _doc-utils: http://docutils.sf.net/
  32. reStructured Text
  33. -----------------
  34. When using the ``restructuredtext`` markup filter you can define a
  35. :setting:`RESTRUCTUREDTEXT_FILTER_SETTINGS` in your django settings to
  36. override the default writer settings. See the `restructuredtext writer
  37. settings`_ for details on what these settings are.
  38. .. _restructuredtext writer settings: http://docutils.sourceforge.net/docs/user/config.html#html4css1-writer