Jaymon / bang

A static site generator with support for RSS feeds, sitemaps, and Google Amp
MIT License
13 stars 0 forks source link

allow adding markdown extensions from config #6

Closed Jaymon closed 5 years ago

Jaymon commented 7 years ago

so generator.Post.normalize_md should have a create_markdown_instance event that passes in args or something so you can manipulate it and override it if you want.

I want this because I want to add a plugin that will add title text to under the images, but I don't think that should be a standard extension, so I want to support adding it for my stuff while allowing other blogs to not have that functionality by default.

Jaymon commented 5 years ago

Markdown instance creation is now context aware, so you can do something like:

@event('context.NAME')
def configure(event_name, config):
    md = config.markdown
    md.register(MyExtension())

to add new extensions to markdown.

To manipulate the default set of extensions that load you can set config.markdown_extensions and that will override any extensions when creating a new Markdown instance, so you should be able to completely customize markdown in your configure.project callback. You can also get the default set of extensions with the Markdown.create_extensions() method.