Browse Source

Docs for markup module

Rafał Pitoń 11 years ago
parent
commit
bdab4c7920
4 changed files with 64 additions and 0 deletions
  1. 1 0
      docs/developers/index.rst
  2. 56 0
      docs/developers/markup.rst
  3. 6 0
      docs/developers/settings.rst
  4. 1 0
      docs/index.rst

+ 1 - 0
docs/developers/index.rst

@@ -46,3 +46,4 @@ Following references cover everything you want to know about writing your own ap
    validators
    validators
    auth
    auth
    acls
    acls
+   markup

+ 56 - 0
docs/developers/markup.rst

@@ -0,0 +1,56 @@
+=============
+Misago Markup
+=============
+
+Misago defines custom ``misago.markup`` module that provides facilities for parsing strings.
+
+This module exposes following functions as its public API:
+
+
+parse
+-----
+
+.. function:: parse(text, author=None, allow_mentions=True, allow_links=True, allow_images=True, allow_blocks=True)
+
+Parses Misago-flavoured Markdown text according to settings provided. Returns dictionary with following keys:
+
+* ``original_text``: original text that was parsed
+* ``parsed_text``: parsed text
+* ``markdown``: markdown instance
+
+
+common_flavour
+--------------
+
+.. function:: common_flavour(text, author=None, allow_mentions=True)
+
+Convenience function that wraps ``parse()``. This function is used for parsing messages.
+
+
+limited_flavour
+--------------
+
+.. function:: limited_flavour(text)
+
+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.
+
+
+Extending Markup
+================
+
+To extend Misago markup, create custom module defining one or both of following functions:
+
+
+.. function:: extend_markdown(md)
+
+Defining this function will allow you to register new extensions in markdown used to parse text.
+
+
+.. function:: process_result(result, soup)
+
+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.
+
+
+Both functions should modify provided arguments in place.
+
+Once your functions are done, add path to your module to ``MISAGO_MARKUP_EXTENSIONS`` setting which is tupe of modules.

+ 6 - 0
docs/developers/settings.rst

@@ -188,6 +188,12 @@ MISAGO_MAILER_BATCH_SIZE
 Default maximum size of single mails package that Misago will build before sending mails and creating next package.
 Default maximum size of single mails package that Misago will build before sending mails and creating next package.
 
 
 
 
+MISAGO_MARKUP_EXTENSIONS
+------------------------
+
+List of python modules extending Misago markup.
+
+
 password_complexity
 password_complexity
 -------------------
 -------------------
 
 

+ 1 - 0
docs/index.rst

@@ -35,3 +35,4 @@ Table of Contents
    developers/validators
    developers/validators
    developers/auth
    developers/auth
    developers/acls
    developers/acls
+   developers/markup