Skip to main content

Some utilities for managing Markdown files with metadata.

Project description

Markdown Site Utils

Some utilities for managing Markdown files with metadata.

The notion is that a content-oriented website may be written as a hierarchical series of Markdown files (with an ".md" extension) underneath some data directory, e.g.:

DATA_DIR/
  index.md
  foo.md
  bar.md
  subdir/
    index.md
    foo.md
    bar.md

Each file may contain metadata, written in TOML in a section at the top, bounded by '+++' lines:

+++
title = "My Page Title"
+++

# Some Markdown

YAML and JSON may also be used. YAML blocks should start and end with lines consisting of three dashes; JSON blocks should consist of a single JSON object with opening and closing braces on lines by themselves. The data block is optional but if present must begin on the first line of the file.

To use the library, you get create an mdsite.DB object with the path to your data directory:

mydb = mdsite.DB("/path/to/data/dir")

Then call get_data(path) for the path into the directory you want, leaving out the .md filename suffix, and, if you are looking for an index file, leaving out index.md:

data = mydb.get_data("/node/leaf")

The above gets data for $DATA_DIR/node/leaf.md, or for $DATA_DIR/node/leaf/index.md, if that file exists instead.

The library also supports hierarchical configuration, also written in TOML, YAML, or JSON, stored in files called config.{toml,yaml,json} depending on the config language employed.

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

markdown_site_utils-0.2.2.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

markdown_site_utils-0.2.2-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

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