NAME
Chandra::Markdown - Render Markdown in Chandra apps
SYNOPSIS
use Chandra::Markdown;
my $md = Chandra::Markdown->new(app => $app);
$md->set("# Hello\nThis is **Markdown**.");
# Render to HTML string without updating the webview
my $html = $md->render("# Hello");
# Register routes for a docs directory + get nav HTML
my $nav = $md->render_dir('docs', base_route => '/docs');
# Add a search widget (registers the bind handler)
my $search = $md->search_widget(placeholder => 'Search docs...');
METHODS
new(%opts)
app is required. Options: gfm (default 1), hard_breaks (default 0), id (default chandra-markdown), css (default 1).
render($markdown)
Convert $markdown to HTML. Does not update the webview.
set($markdown) / append($markdown)
Render and set/append innerHTML of the target element. Return $self.
render_dir($dir, %opts)
Scan $dir for *.md files, register routes and index content for search. Returns a <nav> HTML string. Options: recursive, base_route, nav_id, sort, index.
search($query, $limit)
Search the index built by render_dir. Returns an arrayref of {route, title, score, snippet} hashrefs, sorted by score descending.
search_widget(%opts)
Register the __chandra_md_search invoke handler and return HTML for the search input. Options: placeholder, limit, min_length. Embed the returned HTML in your layout.
AUTHOR
LNATION <email@lnation.org>
LICENSE
Artistic License 2.0