2

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.

Magsol
  • 4,640
  • 11
  • 46
  • 68

1 Answers1

6

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']
Community
  • 1
  • 1
Waylan
  • 37,164
  • 12
  • 83
  • 109
  • Worked like a charm, thanks so much. I figured it was dead simple. I tried following the directions in the Python-Markdown extensions tutorial but kept running into bizarre errors related to the various fields I had to define in `setup.py.` Thanks! – Magsol Jan 02 '16 at 15:34
  • This solution also works for MKDocs. Thanks a lot for your contribution. – Yuan Ma Feb 19 '17 at 19:53
  • 2
    Starting with [**3.7.0**](http://docs.getpelican.com/en/stable/changelog.html?highlight=MD_EXTENSIONS#id2) Pelican version, we need to use [**MARKDOWN setting**](http://docs.getpelican.com/en/stable/settings.html?highlight=MARKDOWN#basic-settings) instead of `MD_EXTENSIONS`. Thanks. – Саша Черных Apr 09 '17 at 05:57
  • Hey @СашаЧерных, were you able to make this work with pelican 3.7 and up (I'm using v4)? I can't get it to work... – haki Dec 28 '18 at 09:06
  • @haki, this works for me in Pelican 4.0.1. Maybe [**`pelicanconf.py` of my project**](https://github.com/Kristinita/KristinitaPelican/blob/master/pelicanconf.py) will help you. Thanks. – Саша Черных Dec 28 '18 at 09:13