Question

I'm writing my first plugin for DocPad and I'm really enjoying the process because it's actually pretty intuitive.

My plugin uses shortcode-parser to parse shortcodes in my markdown-documents.

Here's my problem:

The marked-plugin for DocPad converts " to ", which is totally expected behaviour. However, this breaks my plugin because what was [tagname attribute="some value"] becomes [tagname attribute="some value"].

Possible Solution:

There is already a plugin out there that handles shortcodes. It circumvents this problem by using a file-extension. The reason I wrote my own plugin was (aside from learning DocPad) that I don't want to have to add file extensions to hundreds of documents just to enable my plugin.

Are there any clean alternative besides using file-extensions to prevent render-plugins from clashing? If there was, for example, a configuration-attribute to specify the order in which render-plugins execute – I would consider that a pretty good solution.

Was it helpful?

Solution

I just went with using extensions. The resulting plugin can be found here, if anybody's interested: https://github.com/maximilianschmitt/docpad-plugin-shortcodeparser

If anybody has a better idea to solve this kind of issue, please let me know!

OTHER TIPS

I think it would be handy to have a plugin, that could provide predefined pipelines.
For example:

docpadConfig = {
    plugins:
        PLUGIN:
            main: '.html.md.eco'
}

With this plugin document with extension .main could be processed as if it had extensions '.html.md.eco'.

Not sure, but maybe it's possible to replace pipeline by some query like this:

docpadConfig = {
    collections:
        _main: ->
            @getCollection('html').findAllLive({extension:'main', }).on 'add', (model) ->
                model.setMeta({extensions:['html', 'md', 'eco']})
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top