First time here? Check out the FAQ!

Revision history  [back]

In theory, Askbot uses python-markdown2 so it can do everything described in the markdown2 wiki. However, the current code, i.e. askbot.utils.markdown.get_parser does not enable syntax highlighting.

For a least invasive extension one could subclass markdown2.Markdown, extend the constructor and assign the new subclass to ASKBOT_MARKDOWN_CLASS in settings.py. I didn't test the following, but I am confident solutions look something like this:

  • in somefile.py (in Askbot's PYTHONPATH)

    import markdown2
    
    class MyMarkdown(markdown2.Markdown):
        def __init__(self, *args, **kwargs):
             extras = kwargs.get('extras', list())
             extras.extend(['fenced-code-blocks'])
             kwargs['extras'] = extras
             super(MyMarkdown, self).__init__(*args, **kwargs)
    
  • in settings.py

    ASKBOT_MARKDOWN_CLASS = 'somefile.MyMarkdown'
    

In theory, Askbot uses python-markdown2 so it can do everything described in the markdown2 wiki. However, the current code, i.e. askbot.utils.markdown.get_parser does not enable syntax highlighting.

For a least invasive extension one could subclass markdown2.Markdown, extend the constructor and assign the new subclass to ASKBOT_MARKDOWN_CLASS in settings.py. I didn't test the following, but I am confident solutions look something like this:

  • in somefile.py (in Askbot's PYTHONPATH)

    import markdown2
    
    class MyMarkdown(markdown2.Markdown):
        def __init__(self, *args, **kwargs):
             extras = kwargs.get('extras', list())
             extras.extend(['fenced-code-blocks'])
             kwargs['extras'] = extras
             super(MyMarkdown, self).__init__(*args, **kwargs)
    
  • in settings.py

    import somefile
    ASKBOT_MARKDOWN_CLASS = 'somefile.MyMarkdown'
    

In theory, Askbot uses python-markdown2 so it can do everything described in the markdown2 wiki. However, the current code, i.e. askbot.utils.markdown.get_parser does not enable syntax highlighting.

For a least invasive extension one could subclass markdown2.Markdown, extend the constructor and assign the new subclass to ASKBOT_MARKDOWN_CLASS in settings.py. I didn't test the following, but I am confident solutions look something like this:

  • in somefile.py (in Askbot's PYTHONPATH)

    import markdown2
    
    class MyMarkdown(markdown2.Markdown):
    MyMarkdown(markdown2.Markdown)
        def __init__(self, *args, **kwargs):
             extras = kwargs.get('extras', list())
             extras.extend(['fenced-code-blocks'])
             kwargs['extras'] = extras
             super(MyMarkdown, self).__init__(*args, **kwargs)
    
  • in settings.py

    import somefile
    ASKBOT_MARKDOWN_CLASS = 'somefile.MyMarkdown'
    somefile.MyMarkdown