Skip to content

Commit

Permalink
Merge pull request #5 from pR0Ps/master
Browse files Browse the repository at this point in the history
Misc fixes (basically a rewrite)
  • Loading branch information
joachimneu committed Feb 19, 2015
2 parents 0728c58 + e266d28 commit 058283d
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 296 deletions.
52 changes: 0 additions & 52 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,54 +1,2 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

# Sphinx documentation
docs/_build/

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "markdown_metayaml"]
path = markdown_metayaml
url = https://github.com/teoric/python-markdown-yaml-meta-data.git
63 changes: 23 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pelican-md-yaml
===============
pelican-md-metayaml
===================

This [Pelican](https://github.com/getpelican/pelican) plugin adds a reader for Markdown files with [YAML](https://en.wikipedia.org/wiki/YAML) metadata.
As the well-known static site generator [Jekyll](https://github.com/jekyll/jekyll) uses Markdown files with YAML metadata, this eases migration from Jekyll to Pelican.
Expand All @@ -16,54 +16,37 @@ Dependencies
Installation
------------

Copy the `md_yaml` directory to the `plugins` directory of your Pelican project (or whatever directory you specified for plugins in Pelican's `PLUGIN_PATHS` setting) and add `'md_yaml'` to the list of plugins (Pelican setting `PLUGINS`) of your project.
Clone this repo (and it's submodules) to the `plugins` directory of your Pelican project (or whatever directory you specified for plugins in Pelican's `PLUGIN_PATHS` setting) and add `'md_metayaml'` to the list of plugins (Pelican setting `PLUGINS`) of your project.

To make sure the submodule is included use `git clone --recursive [repo] [path]`
Alternatively, you can clone normally, then run `git submodule update --init` to checkout the submodule

Usage
-----

All your Markdown files (ending in `.md`, `.markdown`, `.mkd` and `.mdown`) will now be interpreted as using YAML for their metadata.

The following example shows a very simple article (only one line of text at the bottom) but with quite complex metadata (everything between the `---`):

```
---
template: article_recipe
title: Tiramisù
components:
- name: Tiramisù
for: 10
ingredients:
- - 4
- eggs
- - 150g
- sugar
- - 10 small cups
- espresso
- - 500g
- mascarpone
- - 1 package
- ladyfingers
title: Some title
author: Some person
tags:
- tag 1
- tag 2
date: 2014-12-25 00:00
data:
- name: some name
options:
- opt 1
- opt 2
- opt 3
steps:
- Cook the espresso, pour it into a soup plate.
- Separate the eggs very carefully.
- Add very little salt to the egg white.
- Blend egg yolk and sugar and mix it extensively for some minutes using a mixer, until you obtain a homogenous mass.
- Add mascarpone and mix again very extensively.
- Beat the egg white and fold it into the other mass.
- Construct the tiramisù: First a layer of cream, then a layer of ladyfingers dipped into espresso, cream, ladyfingers, ..., cream. Sprinkle with cacao.
- Put the tiramisù into the fridge for about a night, serve cold!
- Step 1
- Step 2
- Step 3
---
Thank you Silvia for the recipe!
This is the only text in the article.
```

Warranty
--------

No warranty whatsoever is provided for either the code or the recipe provided above! ;) Use only at your own risk!

References
----------

* This Pelican plugin uses the Markdown extension `mdx_meta_yaml` found here: <https://github.com/teoric/python-markdown-yaml-meta-data>
* The Pelican plugin `markdown-pullquote` was used as an example for a Pelican plugin providing a Markdown extension and can be found here: <https://github.com/arocks/markdown-pullquote>
* A similar approach to YAML metadata in Markdown files can be found here: <http://ianbarton.net/posts/2013/Apr/06/blogging-with-emacs-org-mode-and-pelican/>
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .md_metayaml import *
1 change: 1 addition & 0 deletions markdown_metayaml
Submodule markdown_metayaml added at dd7f3b
29 changes: 29 additions & 0 deletions md_metayaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from pelican import signals
from pelican.readers import MarkdownReader

from .markdown_metayaml.meta_yaml import MetaYamlExtension

class MarkdownYAMLReader(MarkdownReader):
"""Reader for Markdown files with YAML metadata"""

def __init__(self, *args, **kwargs):
super(MarkdownYAMLReader, self).__init__(*args, **kwargs)
self.extensions.append(MetaYamlExtension())

def _parse_metadata(self, meta):
"""Return the dict containing document metadata"""

# MarkdownReader _parse_metadata() expects a list of length 1
# containing a string of comma-seperated values for authors and tags
for x in ("tags", "authors"):
if x in meta:
meta[x] = [",".join(meta[x])]

return super(MarkdownYAMLReader, self)._parse_metadata(meta)

def add_reader(readers):
for k in MarkdownYAMLReader.file_extensions:
readers.reader_classes[k] = MarkdownYAMLReader

def register():
signals.readers_init.connect(add_reader)
1 change: 0 additions & 1 deletion md_yaml/__init__.py

This file was deleted.

63 changes: 0 additions & 63 deletions md_yaml/md_yaml.py

This file was deleted.

30 changes: 0 additions & 30 deletions md_yaml/mdx_meta_yaml/LICENSE.md

This file was deleted.

10 changes: 0 additions & 10 deletions md_yaml/mdx_meta_yaml/__init__.py

This file was deleted.

100 changes: 0 additions & 100 deletions md_yaml/mdx_meta_yaml/extension.py

This file was deleted.

0 comments on commit 058283d

Please sign in to comment.