NAME

Dancer::Plugin::Preprocess::Markdown - Generate HTML content from Markdown files

VERSION

version 0.021

SYNOPSIS

Dancer::Plugin::Preprocess::Markdown automatically generates HTML content from Markdown files in a Dancer web application.

Add the plugin to your application:

use Dancer::Plugin::Preprocess::Markdown;

Configure its settings in the YAML configuration file:

plugins:
  "Preprocess::Markdown":
    save: 1
    paths:
      "/documents":
        recursive: 1
        save: 0
      "/articles":
        src_dir: "articles/markdown"
        dest_dir: "articles/html"
        layout: "article"

DESCRIPTION

Dancer::Plugin::Preprocess::Markdown generates HTML content from Markdown source files.

When an HTML file is requested, and its path matches one of the paths specified in the configuration, the plugin looks for a corresponding Markdown file and processes it to produce the HTML content. The generated HTML file may then be saved and re-used with subsequent requests for the same URL.

CONFIGURATION

The available configuration settings are described below.

Top-level settings

layout

The layout used to display the generated HTML content.

paths

A collection of paths that will be served by the plugin. Each path entry may define path-specific settings that override top-level settings.

recursive

If set to 0, then the plugin only processes files placed in the source directory and not its subdirectories. If set to 1, subdirectories are also processed.

Default: 0

save

If set to 0, then the HTML content is generated on-the-fly with every request. If set to 1, then HTML files are generated once and saved, and are used in subsequent responses. The files are regenerated every time the source Markdown files are modified.

Default: 0

Path-specific settings

src_dir

The directory where source Markdown files are located.

Default: md/src/{path}

dest_dir

The destination directory for the generated HTML files (if the save option is in use).

Default: md/dest/{path}

ROUTE HANDLERS VS. PATHS

If there's a route defined in your application that matches one of the paths served by the plugin, it will take precedence. For example, with the following configuration:

plugins:
  "Preprocess::Markdown":
    paths:
      "/documents":
        ...

and this route in the application:

get '/documents/faq' => sub {
    ...
};

A request for /documents/faq won't be processed by the plugin, but by the handler defined in the application.

SEE ALSO

ACKNOWLEDGEMENTS

Markdown to HTML conversion is done with Text::Markdown, written by Tomas Doran.

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://github.com/odyniec/p5-Dancer-Plugin-Preprocess-Markdown/issues. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/odyniec/p5-Dancer-Plugin-Preprocess-Markdown

git clone https://github.com/odyniec/p5-Dancer-Plugin-Preprocess-Markdown.git

AUTHOR

Michal Wojciechowski <odyniec@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Michal Wojciechowski.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.