Skip to content

Commit

Permalink
GFM reader may not be registered for some MD files
Browse files Browse the repository at this point in the history
This fixes #59 for other extensions
  • Loading branch information
sebbASF committed Jun 11, 2023
1 parent b6cea95 commit da5fa96
Showing 1 changed file with 9 additions and 4 deletions.
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)

0 comments on commit da5fa96

Please sign in to comment.