NAME

Markdown::Perl – Very configurable Markdown processor written in pure Perl, supporting the CommonMark spec and many extensions.

SYNOPSIS

This is the library underlying the pmarkdown tool. It can be used in an object-oriented style:

use Markdown::Perl;
my $converter = Markdown::Perl->new([mode => $mode], %options);
my $html = $converter->convert($markdown);

Or the library can be used functionally:

use Markdown::Perl 'convert';
Markdown::Perl::set_options([mode => $mode], %options);
my $html = convert($markdown);

DESCRIPTION

new

my $pmarkdown = Markdown::Perl->new([mode => $mode], %options);

Creates a Markdown::Perl object that can be used to convert Markdown data into HTML. Note that you don’t have to create an instance of this class to use this module. The methods of this class can also be used like package functions and they will operate on an implicit default instance of the class.

See the "MODES" in pmarkdown page for the documentation of existing modes.

See the Markdown::Perl::Options documentation for all the existing options.

For the reference on the default syntax supported by the library, see the GitHub repository of the project: https://github.com/mkende/pmarkdown/blob/main/Syntax.md

set_options

$pmarkdown->set_options(%options);
Markdown::Perl::set_options(%option);

Sets the options of the current object or, for the functional version, the options used by functional calls to convert(). The options set through the functional version do not apply to any objects created through a call to new().

See the Markdown::Perl::Options documentation for all the existing options.

set_mode

$pmarkdown->set_mode($mode);
Markdown::Perl::set_mode($mode);

Specifies a mode for the current object or, for the functional version, the mode used by functional calls to convert(). A mode is a set of configuration options working together, typically to replicate the semantics of another existing Markdown processor. See the "MODES" in pmarkdown documentation for a list of available modes.

When a mode is applied, it sets specific values for some options but any value for these options set through the set_options() will take precedence, even if set_options() is called before set_mode(). The mode set through the functional version does not apply to any objects created through a call to new().

convert

my $html = $pmarkdown->convert($md);
my $html = Markdown::Perl::convert($md);

Converts the given $md string into HTML. The input string must be a decoded Unicode string (or an ASCII string) and the output is similarly a decoded Unicode string.

AUTHOR

Mathias Kende <mathias@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2024 Mathias Kende

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

SEE ALSO

pmarkdown
Text::Markdown another pure Perl implementation, implementing the original Markdown syntax from http://daringfireball.net/projects/markdown.
CommonMark a wrapper around the official CommonMark C library.