Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The installation notes (git://gitorious.org/python-markdown/mainline.git) say in the file using_as_module.txt

One of the parameters that you can pass is a list of Extensions. Extensions must be available as python modules either within the markdown.extensions package or on your PYTHONPATH with names starting with mdx_, followed by the name of the extension. Thus, extensions=['footnotes'] will first look for the module markdown.extensions.footnotes, then a module named mdx_footnotes. See the documentation specific to the extension you are using for help in specifying configuration settings for that extension.

I put the folder "extensions" to ~/bin/python/ such that my PYTHONPATH is the following

export PYTHONPATH=/Users/masi/bin/python/:/opt/local/Library/Frameworks/Python.framework/Versions/2.6/

The instructions say that I need to import the addons such that

import markdown
import <module-name>

However, I cannot see any module in my Python. This suggests me that the extensions are not available as "python modules - - on [my] PYTHONPATH with names starting with mdx_ - -."

How can you get Markdown's extensions to work?


2nd attempt

I run at ~/bin/markdown

git clone git://gitorious.org/python-markdown/mainline.git python-markdown
cd python-markdown
python setup.py install

I put the folder /Users/masi/bin/markdown/python-markdown/build to my PATH because the installation message suggests me that is the new location of the extensions.

I have the following in a test markdown -document

[TOC]
-- headings here with # -format ---

However, I do not get the table of contents. This suggests me that we need to somehow activate the extensions when we compile by the markdown.py -script. **The problem returns to my first quoted text which I is rather confusing to me.

share|improve this question
up vote 6 down vote accepted

I like to setup a virtualenv when I use python for any sort of project. So on debian based systems I install pip and virtualenv

sudo aptitude install python-pip python-virtualenv

Then if using python markdown, I would make my virtual environment and use pip to install python-markdown and ElementTree

virtualenv mynewbook
pip -E mynewbook install -U Markdown ElementTree

To make life easier I usually set my environment to the local virtual environment after changing to the new project directory

cd mynewbook
source bin/activate

Then with my book in the file mybook.markdown with the format

[TOC]

Heading-a
==========

---text---

Heading-b
------------

I just have to run

markdown mybook.markdown -f mybook.html -x toc

When you're done with your virtual environment it's as simple as typing

deactivate
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .