Skip to main content

Allow definition of custom metadata parsers for Pelican content

Project description

A plugin for Pelican that allows the easy definition of custom metadata parsers.

Install

To install the library, you can use pip

$ pip install pelican-metadataparsing

Usage

  1. Update pelicanconf.py:

    1. Add metadataparsing to PLUGINS.

      You should add it before any metadata-affecting plugins.

      PLUGINS = [..., 'metadataparsing', ...]
    2. Define your custom metadata parsers through the METADATA_PARSERS setting:

      METADATA_PARSERS = {
          "<metadata-field-name1>": <function parser1(x)>,
          "<metadata-field-name2>": <function parser2(x)>
      }
  2. Corresponding fields of the page, article or entity object will have the value returned from the respective parser function.

Example

Multi-line metadata to simple string

import collections
import six

def parse_description(string):
    if string is None or isinstance(string, six.string_types):
        return string

    if isinstance(string, collections.Iterable):
        string = " ".join(string)

    return string


METADATA_PARSERS = {
    "Description": parse_description
}

For a working example check my site and my site’s source code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pelican-metadataparsing-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

File details

Details for the file pelican-metadataparsing-0.1.0.tar.gz.

File metadata

File hashes

Hashes for pelican-metadataparsing-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0a36518c612570882f376ca184c3436ef024b35ea93d56556efbab1277df72ef
MD5 6c685ff3ae7205c54ac5beaa1f63518e
BLAKE2b-256 4bdb4abf2b78842861d3035b4de94919cd6ac39f7e84a8b5084af251c7934e6a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page