Add MARKDOWN_EXTENTIONS configuration parameter to enable Markdown extentions of your choice.

Ex: MARKDOWN_EXTENTIONS = [ 'toc', ] enable TOC markup to generate Table of Contents.
This commit is contained in:
stephane 2012-09-27 19:49:42 +02:00
commit 4f5253bcb3
2 changed files with 4 additions and 3 deletions

View file

@ -18,7 +18,6 @@ import re
from pelican.contents import Category, Tag, Author from pelican.contents import Category, Tag, Author
from pelican.utils import get_date, pelican_open from pelican.utils import get_date, pelican_open
_METADATA_PROCESSORS = { _METADATA_PROCESSORS = {
'tags': lambda x, y: [Tag(tag, y) for tag in unicode(x).split(',')], 'tags': lambda x, y: [Tag(tag, y) for tag in unicode(x).split(',')],
'date': lambda x, y: get_date(x), 'date': lambda x, y: get_date(x),
@ -125,12 +124,13 @@ class RstReader(Reader):
class MarkdownReader(Reader): class MarkdownReader(Reader):
enabled = bool(Markdown) enabled = bool(Markdown)
file_extensions = ['md', 'markdown', 'mkd'] file_extensions = ['md', 'markdown', 'mkd']
extensions = ['codehilite', 'extra'] extensions = ['codehilite', 'extra' ]
def read(self, filename): def read(self, filename):
"""Parse content and metadata of markdown files""" """Parse content and metadata of markdown files"""
markdown_extentions = self.settings.get('MARKDOWN_EXTENTIONS', [])
text = pelican_open(filename) text = pelican_open(filename)
md = Markdown(extensions=set(self.extensions + ['meta'])) md = Markdown(extensions=set(self.extensions + markdown_extentions + ['meta']))
content = md.convert(text) content = md.convert(text)
metadata = {} metadata = {}

View file

@ -75,6 +75,7 @@ _DEFAULT_CONFIG = {'PATH': '.',
'SUMMARY_MAX_LENGTH': 50, 'SUMMARY_MAX_LENGTH': 50,
'WEBASSETS': False, 'WEBASSETS': False,
'PLUGINS': [], 'PLUGINS': [],
'MARKDOWN_EXTENTIONS': [],
} }