markup.rst 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. limited_flavour
  18. --------------
  19. .. function:: limited_flavour(text)
  20. Convenience function that wraps ``parse()``. This function is used for parsing short messages and supports only subset of full markup. Unlike other functions, this one returns parsed string instead of dict.
  21. Extending Markup
  22. ================
  23. To extend Misago markup, create custom module defining one or both of following functions:
  24. .. function:: extend_markdown(md)
  25. Defining this function will allow you to register new extensions in markdown used to parse text.
  26. .. function:: process_result(result, soup)
  27. 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.
  28. Both functions should modify provided arguments in place.
  29. Once your functions are done, add path to your module to ``MISAGO_MARKUP_EXTENSIONS`` setting which is tupe of modules.