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