duncan­lock­.net
A dummy placeholder image, 200x200 pixels square.
Figure 1. This figure has automatic figure numbering.

I had a feature request for automatic figure numbering, like latex. I was revamping this plugin for Pelican 3.3 anyway - and this didn’t seem too hard - so I decided to add it.

So, the Better Figures & Images plugin now supports automatic figure numbering. To enable this for all posts, just add this to your config file:

FIGURE_NUMBERS = True

If you want to enable this per post, just add this to the metadata at the top of the post:

for restructuredText add this:

:figure_numbers: true

and for Markdown add this:

figure_numbers: true
Caution:

Can you have Figures in Markdown?

I use reStructuredText for this site, and I’m not sure if you can even have Figures in Markdown documents - and I haven’t tested it, so caveat emptor …

Continue reading “The Better Figures & Images Pelican plugin now supports Figure Numbering”

This is a Pelican plugin to calculate various statistics about a post and store them in an article.stats dictionary. You can see this in action in the sidebar on the left of this site.

Nice touch from medium.com - now available in Pelican.

I wanted to implement the nice little “X min read” thing from Medium - and it turned out that it was easy to provide a few other interesting stats at the same time, for people to use in their templates.

The returned article.stats dictionary contains the following:

  • wc: how many words
  • read_mins: how many minutes would it take to read this article, based on 250 wpm
  • word_counts: frequency count of all the words in the article; can be used for tag/word clouds
  • fi: Flesch-kincaid Index/ Reading Ease
  • fk: Flesch-kincaid Grade Level

For example:

{
    'wc': 2760,
    'fi': '65.94',
    'fk': '7.65',
    'word …
Continue reading “Post Statistics Plugin for Pelican”

How Figures & Images work in Pelican, by default

By default Pelican does a great job with figures and images, thanks to built-in support in ReStructuredText [1][1] . Pelican will turn this rst input:

.. figure:: {static}/images/better-figures-images-plugin-for-pelican/dummy-200x200.png
    :align: right

    This is the caption of the figure.

    The legend consists of all elements after the caption. In this case, the legend consists of this paragraph.

into this HTML output:

<div class="figure align-right">
    <img alt="/static/images/dummy-200x200.png" src="/static/images/dummy-200x200.png" />
    <p class="caption">This is the caption of the figure.</p>
    <div class="legend">The legend consists of all elements after the caption. In this case, the legend consists of this paragraph</div>
</div>

Which, given this CSS:

/* Styles for Figures & Images */

img {
    border: 1px solid #bbb;
    border-radius: 3px;
    padding: 4px;
    float: left;
    margin: 1em …
Continue reading “Better Figures & Images Plugin for Pelican”