@ -4,27 +4,37 @@
# Markdown -- A text-to-HTML conversion tool for web writers
#
# Copyright (C) 2004 John Gruber
# Copyright (C) 2015,2016 Kyle J. McKay
# Copyright (C) 2015,2016,2017 Kyle J. McKay
# All rights reserved.
# License is Modified BSD (aka 3-clause BSD) License\n";
# See LICENSE file (or <https://opensource.org/licenses/BSD-3-Clause>)
#
package Markdown ;
require 5.006_000 ;
use strict ;
use warnings ;
use vars qw( $COPYRIGHT $VERSION @ISA @EXPORT_OK ) ;
BEGIN { * COPYRIGHT =
\ " Copyright ( C ) 2004 John Gruber
Copyright ( C ) 2015 , 2016 , 2017 Kyle J . McKay
All rights reserved .
" ;
* VERSION = \ "1.0.4+" # Sun 05 Jun 2016+
}
close ( DATA ) if fileno ( DATA ) ;
require Exporter ;
use Digest::MD5 qw( md5_hex ) ;
use File::Basename qw( basename ) ;
use vars qw( $VERSION @ISA @EXPORT_OK ) ;
@ ISA = qw( Exporter ) ;
@ EXPORT_OK = qw( Markdown ) ;
$ INC { __PACKAGE__ . '.pm' } = $ INC { basename ( __FILE__ ) } unless exists $ INC { __PACKAGE__ . '.pm' } ;
$ VERSION = '1.0.4' ;
# Sun 05 Jun 2016
## Disabled; causes problems under Perl 5.6.1:
# use utf8;
@ -58,7 +68,7 @@ $g_nested_brackets = qr{
# Table of hash values for escaped characters:
my % g_escape_table ;
foreach my $ char ( split // , "\\\`*_{}[]()>#+-.!~ " ) {
foreach my $ char ( split // , "\\\`*_~ {}[]()>#+-.!" ) {
$ g_escape_table { $ char } = md5_hex ( $ char ) ;
}
@ -86,9 +96,9 @@ sub start { 1; }
sub story {
my ( $ pkg , $ path , $ filename , $ story_ref , $ title_ref , $ body_ref ) = @ _ ;
if ( ( ! $ g_blosxom_use_meta ) or
if ( ( ! $ g_blosxom_use_meta ) or
( defined ( $ meta:: markup ) and ( $ meta:: markup =~ /^\s*markdown\s*$/i ) )
) {
) {
$$ body_ref = Markdown ( $$ body_ref ) ;
}
1 ;
@ -213,9 +223,9 @@ elsif (!caller) {
exec 'perldoc' , $ 0 ;
}
if ( $ cli_opts { 'version' } ) { # Version info
print "\nThis is Markdown, version $VERSION.\n" ;
print "Copyright (C) 2004 John Gruber \n" ;
print "Copyright (C) 2015 Kyle J. McKay \n" ;
print "\nThis is Markdown, version $VERSION.\n" , $ COPYRIGHT ;
print "License is Modified BSD (aka 3-clause BSD) License \n" ;
print "<https://opensource.org/licenses/BSD-3-Clause> \n" ;
exit 0 ;
}
if ( $ cli_opts { 'shortversion' } ) { # Just the version number string.
@ -557,7 +567,7 @@ sub _RunSpanGamut {
$ text = _DoItalicsAndBoldAndStrike ( $ text ) ;
# Do hard breaks:
$ text =~ s/ {2,}\n/ <br$opt{empty_element_suffix}\n/g ;
$ text =~ s/ {2,}\n/<br$opt{empty_element_suffix}\n/g ;
return $ text ;
}
@ -891,7 +901,7 @@ sub _DoLists {
# We use a different prefix before nested lists than top-level lists.
# See extended comment in _ProcessListItems().
#
# Note: There's a bit of duplication here. My original implementation
# Note: (jg) There's a bit of duplication here. My original implementation
# created a scalar regex pattern as the conditional result of the test on
# $g_list_level, and then only ran the $text =~ s{...}{...}egmx
# substitution once, using the scalar as the pattern. This worked,
@ -1169,14 +1179,14 @@ sub _DoBlockQuotes {
$ bq =~ s/^[ \t]+$//mg ; # trim whitespace-only lines
$ bq = _RunBlockGamut ( $ bq ) ; # recurse
$ bq =~ s/^/ / g ;
$ bq =~ s/^/ /m g ;
# These leading spaces screw with <pre> content, so we need to fix that:
$ bq =~ s {
( \ s * <pre> . + ? </pre> )
( \ s * ) ( <pre> . + ? </pre> )
} {
my $ pre = $ 1 ;
my ( $ indent , $ pre ) = ( $ 1 , $ 2 ) ;
$ pre =~ s/^ //mg ;
$ pre ;
$ indent . $ pre ;
} egsx ;
"<blockquote>\n$bq\n</blockquote>\n\n" ;
@ -1243,8 +1253,7 @@ sub _EncodeAmpsAndAngles {
sub _EncodeBackslashEscapes {
#
# Parameter: String.
# Returns: The string, with after processing the following backslash
# escape sequences.
# Returns: String after processing the following backslash escape sequences.
#
local $ _ = shift ;
@ -1273,7 +1282,7 @@ sub _EncodeBackslashEscapes {
sub _DoAutoLinks {
my $ text = shift ;
$ text =~ s{<((https?|ftp):[^'\042>\s]+)>} {< a href="$1">$1</a> }gi ;
$ text =~ s{<((https?|ftp):[^'\042>\s]+)>} {<< a href="$1">$1</a>> }gi ;
# Email addresses: <address@domain.foo>
$ text =~ s {
@ -1286,7 +1295,7 @@ sub _DoAutoLinks {
)
>
} {
_EncodeEmailAddress ( _UnescapeSpecialChars ( $ 1 ) ) ;
"<" . _EncodeEmailAddress ( _UnescapeSpecialChars ( $ 1 ) ) . ">" ;
} egix ;
return $ text ;
@ -1449,8 +1458,7 @@ __DATA__
= head1 NAME
B <Markdown>
Markdown . pl - convert Markdown format text files to HTML
= head1 SYNOPSIS
@ -1471,8 +1479,8 @@ specifically to serve as a front-end to (X)HTML. You can use span-level
HTML tags anywhere in a Markdown document , and you can use block level
HTML tags ( like <div> and <table> as well ) .
For more information about Markdown ' s syntax , see the `basics.text`
and `syntax.text` files included with `Markdown.pl` .
For more information about Markdown ' s syntax , see the F <basics.md>
and F <syntax.md> files included with F <Markdown.pl> .
= head1 OPTIONS
@ -1481,7 +1489,7 @@ Use "--" to end switch parsing. For example, to open a file named "-z", use:
Markdown . pl - - - z
= over 4
= over
= item B <--html4tags>
@ -1526,52 +1534,90 @@ Display Markdown's help.
= head1 VERSION HISTORY
See the readme file for detailed release notes for this version .
Z < > See the F <README> file for detailed release notes for this version .
= over
1.0 .4 - 05 Jun 2016
= item Z < > 1.0 .4 - 05 Jun 2016
1.0 .3 - 06 Sep 2015
= item Z < > 1.0 .3 - 06 Sep 2015
1.0 .2 - 03 Sep 2015
= item Z < > 1.0 .2 - 03 Sep 2015
1.0 .1 - 14 Dec 2004
= item Z < > 1.0 .1 - 14 Dec 2004
1.0 - 28 Aug 2004
= item Z < > 1.0 .0 - 28 Aug 2004
= back
= head1 AUTHORS
John Gruber
http: // daringfireball . net
http: // daringfireball . net /projects/m arkdown /
= over
= item John Gruber
= item L <http://daringfireball.net>
PHP port and other contributions by Michel Fortin
http: //mic helf . com
= item L <http://daringfireball.net/projects/markdown/>
Additional enhancements and tweaks by Kyle J . McKay
mackyle <at> gmail . com
= item E <160>
= back
= over
= item PHP port and other contributions by Michel Fortin
= item L <http://michelf.com>
= item E <160>
= back
= over
= item Additional enhancements and tweaks by Kyle J . McKay
= item mackyle <at> gmail . com
= back
= head1 COPYRIGHT AND LICENSE
Copyright ( C ) 2003 - 2004 John Gruber
Copyright ( C ) 2015 , 2016 Kyle J . McKay
All rights reserved .
= over
= item Copyright ( C ) 2003 - 2004 John Gruber
= item Copyright ( C ) 2015 , 2016 Kyle J . McKay
= item All rights reserved .
= back
Redistribution and use in source and binary forms , with or without
modification , are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice , this list of conditions and the following disclaimer .
= over
= item *
Redistributions of source code must retain the above copyright
notice , this list of conditions and the following disclaimer .
* Redistributions in binary form must reproduce the above copyright
notice , this list of conditions and the following disclaimer in the
documentation and / or other materials provided with the distribution .
= item *
* Neither the name "Markdown" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission .
Redistributions in binary form must reproduce the above copyright
notice , this list of conditions and the following disclaimer in the
documentation and / or other materials provided with the distribution .
= item *
Neither the name "Markdown" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission .
= back
This software is provided by the copyright holders and contributors " as
is " and any express or implied warranties , including , but not limited