package Text::Markdown::Discount; use 5.008000; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use Text::Markdown::XS ':all'; # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our %EXPORT_TAGS = ( 'all' => [ qw( markdown ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( ); our $VERSION = '0.08'; require XSLoader; XSLoader::load('Text::Markdown::Discount', $VERSION); sub new { return bless {}, 'Text::Markdown::Discount'; } sub markdown { my ($self, $text, $flags, $opts) = @_; if (not defined $flags) { $flags = MKD_NOHEADER()|MKD_NOPANTS(); } if (not defined $opts or ref($opts) ne 'HASH') { $opts = {}; } my $with_html5 = $opts->{with_html5} ? 1 : 0; # Detect functional mode, and create an instance for this run.. unless (ref $self) { if ( $self ne __PACKAGE__ ) { my $ob = __PACKAGE__->new(); # $self is text, $text is options return $ob->markdown($self, $text, $flags, $with_html5); } else { croak('Calling ' . $self . '->markdown (as a class method) is not supported.'); } } return _markdown($text, $flags, $with_html5); } 1; __END__ # Below is stub documentation for your module. You'd better edit it! =head1 NAME Text::Markdown::Discount - fast function for converting markdown to HTML (requires C compiler) =head1 SYNOPSIS use Text::Markdown::Discount; my $html = markdown($text) =head1 DESCRIPTION Text::Markdown::Discount is a perl interface to the C library, a C implementation of John Gruber's C. It is the fastest of the Perl modules available for converting markdown: see the list in L<"SEE ALSO">. It passes Gruber's Markdown testsuite. Given that the performance of Discount, Text::Markdown::Discount processes markdown formatted text quickly and passes the Markdown test suite at The interface of the C function in this module is not compatible with the C function in L. =head2 EXPORT I is exported by default. =head1 SEE ALSO There are other modules on CPAN for converting Markdown: =over 4 =item * L is a pure-perl markdown converter. =item * L is a toolkit for parsing markdown, which can also be used to convert markdown to HTML. =item * L is a converter than can handle a number of input formats, including markdown. =item * L converts MultiMarkdown (a superset of the original markdown format) to HTML. =back Additional markdown resources: =over 4 =item * L - David Loren Parsons's library for converting markdown, written in C. =item * L - John Gruber's original definition of the markdown format. =item * L - John Gruber's testsuite for markdown. =item * L - a review of all Perl modules for handling markdown, written by Neil Bowers. =back =head1 AUTHOR Masayoshi Sekimura, Esekimura@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2009 by Masayoshi Sekimura This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. This product includes software developed by David Loren Parsons =cut