Ask Your Question
1

How can I enable Python Code Highlighting in Askbot?

asked 2023-04-06 23:13:58 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-04-06 23:24:19 +0000

qstack gravatar image

updated 2023-04-07 18:16:33 +0000

Step 1: Put this in a file named markdown_wrapper.py in the project directory where you also find manage.py (Usually one level above the settings.py).

import markdown 
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)

Step 2: Add this line to the settings py:

ASKBOT_MARKDOWN_CLASS = 'markdown_wrapper.MyMarkdown'

Restart the server. The code highlighting should work now (not in editing mode, but you will see it after the question was published.)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

1 follower

Stats

Asked: 2023-04-06 23:13:58 +0000

Seen: 849 times

Last updated: Apr 07 '23