markup.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. =============
  2. Misago Markup
  3. =============
  4. Misago defines custom ``misago.markup`` module that provides facilities for parsing strings.
  5. This module exposes following functions as its public API:
  6. parse
  7. -----
  8. .. function:: parse(text, author=None, allow_mentions=True, allow_links=True, allow_images=True, allow_blocks=True)
  9. Parses Misago-flavoured Markdown text according to settings provided. Returns dictionary with following keys:
  10. * ``original_text``: original text that was parsed
  11. * ``parsed_text``: parsed text
  12. * ``markdown``: markdown instance
  13. common_flavour
  14. --------------
  15. .. function:: common_flavour(text, author=None, allow_mentions=True)
  16. Convenience function that wraps ``parse()``. This function is used for parsing messages.
  17. Extending Markup
  18. ================
  19. To extend Misago markup, create custom module defining one or both of following functions:
  20. .. function:: extend_markdown(md)
  21. Defining this function will allow you to register new extensions in markdown used to parse text.
  22. .. function:: process_result(result, soup)
  23. This function is called to allow additional changes in result dict as well as extra instrospection and cleanup of parsed text, which is provided as `Beautiful Soup <http://www.crummy.com/software/BeautifulSoup/bs4/doc/>`_ class instance.
  24. Both functions should modify provided arguments in place.
  25. Once your functions are done, add path to your module to ``MISAGO_MARKUP_EXTENSIONS`` setting which is tupe of modules.