Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GFM reader may not be registered for some MD files #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions plugins/gfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,13 @@ class GFMReader(pelican.readers.BaseReader):
further is required by users of this Reader.
"""

# NOTE: the builtin MarkdownReader must be disabled. Otherwise, it will be
# non-deterministic which Reader will be used for these files.
# NOTE: the builtin MarkdownReader should ideally be disabled to ensure it is not used
# For example, by not installing the markdown module.
# This may be tricky to do, so to ensure this class is used to process Markdown files,
# we reset the reader_classes list on receipt of the readers_init signal
# This is a bit of a hack, as it relies on the internal Pelican code.
# An alternative approach might be to adjust the READERS config setting.
# This is processed after the BaseReader subclasses, and that is unlikely to change.
file_extensions = ['md', 'markdown', 'mkd', 'mdown']

# Metadata is specified as a single, colon-separated line, such as:
Expand Down Expand Up @@ -229,8 +234,8 @@ def render(self, text):


def add_readers(readers):
readers.reader_classes['md'] = GFMReader

for ext in GFMReader.file_extensions:
readers.reader_classes[ext] = GFMReader

def register():
pelican.plugins.signals.readers_init.connect(add_readers)