Search code examples
python-2.7markdownpelican

Install third-party Markdown extension in Pelican


I'm using Pelican for a static blog, and attempting to install the figure-ref extension. Since I'm using Markdown, the plugin relies on the figureAltCaption third-party Markdown extension. However I have no idea how to install it.

Pelican has an MD_EXTENSIONS configuration option, but I've tried a few obvious options with no luck. It seems like this is a dead-simple gimme but it's not clear how to proceed. Would love some suggestions.


Solution

  • Unfortunately, the author of figureAltCaption appears to have not provided an install script. My suggestion would be to create one and contribute it as a pull request. This tutorial about creating Extensions for Python-Markdown covers creating an install script as well.

    However, as a shortcut, you should be able to just copy the figureAltCaption.py file to the appropriate directory. Usually you want the site-packages directory. As this answer shows, just do the following from Python:

    >>> import site; site.getsitepackages()
    

    Then copy the figureAltCaption.py file to the first directory returned.

    Now that the extension is on your PYTHONPATH, it should be importable. From the Python prompt, try:

    import figureAltCaption
    

    If you get no errors, then it worked and you just need to tell Pelican about it.

    MD_EXTENSIONS = ['figureAltCaption']