@@ -1,5 +1,14 @@
This file documents the revision history for Perl extension Text::MultiMarkdown.
+1.000035 2014-06-19T16:55:00
+ - Add a 'self_url' configuration parameter to the constructor. If set, the
+ value is prepended to the "#" anchor of footnotes.
+
+ - Metadata is now properly encoded - special characters (like angles,
+ ampersand, or quotes) are encoded to generate valid (X)HTML.
+
+ - Add HTML::Entities as an explicit dependency.
+
1.0.34 2011-04-26T10:25:00
- Add definition list support from the MultiMarkdown spec.
@@ -44,6 +44,7 @@ t/30disable_multimarkdown_features.t
t/35commandlinemultimarkdown.t
t/36footnotes.t
t/37deflists.t
+t/38self_url.t
t/docs-maruku-unittest/abbreviations.html
t/docs-maruku-unittest/abbreviations.text
t/docs-maruku-unittest/alt.html
@@ -3,15 +3,16 @@ abstract: 'Convert MultiMarkdown syntax to (X)HTML'
author:
- 'Tomas Doran <bobtfish@bobtfish.net>'
build_requires:
- ExtUtils::MakeMaker: 6.42
+ ExtUtils::MakeMaker: 6.59
FindBin: 0
List::MoreUtils: 0
Test::Exception: 0
Test::More: 0.42
configure_requires:
- ExtUtils::MakeMaker: 6.42
+ ExtUtils::MakeMaker: 6.59
distribution_type: module
-generated_by: 'Module::Install version 0.91'
+dynamic_config: 1
+generated_by: 'Module::Install version 1.08'
license: bsd
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -24,10 +25,11 @@ no_index:
requires:
Digest::MD5: 0
Encode: 0
+ HTML::Entities: 0
Text::Markdown: 1.0.26
perl: 5.8.0
resources:
bugtracker: http://github.com/bobtfish/text-multimarkdown/issues
license: http://opensource.org/licenses/bsd-license.php
repository: http://github.com/bobtfish/text-multimarkdown/
-version: 1.000034
+version: 1.000035
@@ -14,6 +14,7 @@ perl_version '5.008';
requires 'Digest::MD5' => undef;
requires 'Text::Markdown' => '1.0.26';
requires 'Encode' => undef;
+requires 'HTML::Entities' => undef;
build_requires 'Test::More' => '0.42';
build_requires 'Test::Exception' => undef;
build_requires 'List::MoreUtils' => undef;
@@ -119,6 +119,7 @@ OPTIONS
document_format
use_wikilinks
base_url
+ self_url - The document url is prepended to the "#" anchor of footnotes.
METADATA
MultiMarkdown supports the concept of 'metadata', which allows you to
@@ -4,7 +4,7 @@ package Module::Install::Base;
use strict 'vars';
use vars qw{$VERSION};
BEGIN {
- $VERSION = '0.99';
+ $VERSION = '1.08';
}
# Suspend handler for "redefined" warnings
@@ -3,13 +3,12 @@ package Module::Install::Can;
use strict;
use Config ();
-use File::Spec ();
use ExtUtils::MakeMaker ();
use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.99';
+ $VERSION = '1.08';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -29,7 +28,7 @@ sub can_use {
eval { require $mod; $pkg->VERSION($ver || 0); 1 };
}
-# check if we can run some command
+# Check if we can run some command
sub can_run {
my ($self, $cmd) = @_;
@@ -38,14 +37,88 @@ sub can_run {
for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
next if $dir eq '';
- my $abs = File::Spec->catfile($dir, $_[1]);
+ require File::Spec;
+ my $abs = File::Spec->catfile($dir, $cmd);
return $abs if (-x $abs or $abs = MM->maybe_command($abs));
}
return;
}
-# can we locate a (the) C compiler
+# Can our C compiler environment build XS files
+sub can_xs {
+ my $self = shift;
+
+ # Ensure we have the CBuilder module
+ $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 );
+
+ # Do we have the configure_requires checker?
+ local $@;
+ eval "require ExtUtils::CBuilder;";
+ if ( $@ ) {
+ # They don't obey configure_requires, so it is
+ # someone old and delicate. Try to avoid hurting
+ # them by falling back to an older simpler test.
+ return $self->can_cc();
+ }
+
+ # Do we have a working C compiler
+ my $builder = ExtUtils::CBuilder->new(
+ quiet => 1,
+ );
+ unless ( $builder->have_compiler ) {
+ # No working C compiler
+ return 0;
+ }
+
+ # Write a C file representative of what XS becomes
+ require File::Temp;
+ my ( $FH, $tmpfile ) = File::Temp::tempfile(
+ "compilexs-XXXXX",
+ SUFFIX => '.c',
+ );
+ binmode $FH;
+ print $FH <<'END_C';
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+int main(int argc, char **argv) {
+ return 0;
+}
+
+int boot_sanexs() {
+ return 1;
+}
+
+END_C
+ close $FH;
+
+ # Can the C compiler access the same headers XS does
+ my @libs = ();
+ my $object = undef;
+ eval {
+ local $^W = 0;
+ $object = $builder->compile(
+ source => $tmpfile,
+ );
+ @libs = $builder->link(
+ objects => $object,
+ module_name => 'sanexs',
+ );
+ };
+ my $result = $@ ? 0 : 1;
+
+ # Clean up all the build files
+ foreach ( $tmpfile, $object, @libs ) {
+ next unless defined $_;
+ 1 while unlink;
+ }
+
+ return $result;
+}
+
+# Can we locate a (the) C compiler
sub can_cc {
my $self = shift;
my @chunks = split(/ /, $Config::Config{cc}) or return;
@@ -78,4 +151,4 @@ if ( $^O eq 'cygwin' ) {
__END__
-#line 156
+#line 236
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.99';
+ $VERSION = '1.08';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -8,7 +8,7 @@ use Fcntl qw/:flock :seek/;
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.99';
+ $VERSION = '1.08';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -215,18 +215,22 @@ sub write {
require ExtUtils::MakeMaker;
if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) {
- # MakeMaker can complain about module versions that include
- # an underscore, even though its own version may contain one!
- # Hence the funny regexp to get rid of it. See RT #35800
- # for details.
- my $v = $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/;
- $self->build_requires( 'ExtUtils::MakeMaker' => $v );
- $self->configure_requires( 'ExtUtils::MakeMaker' => $v );
+ # This previous attempted to inherit the version of
+ # ExtUtils::MakeMaker in use by the module author, but this
+ # was found to be untenable as some authors build releases
+ # using future dev versions of EU:MM that nobody else has.
+ # Instead, #toolchain suggests we use 6.59 which is the most
+ # stable version on CPAN at time of writing and is, to quote
+ # ribasushi, "not terminally fucked, > and tested enough".
+ # TODO: We will now need to maintain this over time to push
+ # the version up as new versions are released.
+ $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 );
+ $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 );
} else {
# Allow legacy-compatibility with 5.005 by depending on the
# most recent EU:MM that supported 5.005.
- $self->build_requires( 'ExtUtils::MakeMaker' => 6.42 );
- $self->configure_requires( 'ExtUtils::MakeMaker' => 6.42 );
+ $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 );
+ $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 );
}
# Generate the MakeMaker params
@@ -241,7 +245,6 @@ in a module, and provide its file path via 'version_from' (or
'all_from' if you prefer) in Makefile.PL.
EOT
- $DB::single = 1;
if ( $self->tests ) {
my @tests = split ' ', $self->tests;
my %seen;
@@ -412,4 +415,4 @@ sub postamble {
__END__
-#line 541
+#line 544
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.99';
+ $VERSION = '1.08';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -151,15 +151,21 @@ sub install_as_site { $_[0]->installdirs('site') }
sub install_as_vendor { $_[0]->installdirs('vendor') }
sub dynamic_config {
- my $self = shift;
- unless ( @_ ) {
- warn "You MUST provide an explicit true/false value to dynamic_config\n";
- return $self;
+ my $self = shift;
+ my $value = @_ ? shift : 1;
+ if ( $self->{values}->{dynamic_config} ) {
+ # Once dynamic we never change to static, for safety
+ return 0;
}
- $self->{values}->{dynamic_config} = $_[0] ? 1 : 0;
+ $self->{values}->{dynamic_config} = $value ? 1 : 0;
return 1;
}
+# Convenience command
+sub static_config {
+ shift->dynamic_config(0);
+}
+
sub perl_version {
my $self = shift;
return $self->{values}->{perl_version} unless @_;
@@ -170,7 +176,7 @@ sub perl_version {
# Normalize the version
$version = $self->_perl_version($version);
- # We don't support the reall old versions
+ # We don't support the really old versions
unless ( $version >= 5.005 ) {
die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n";
}
@@ -515,6 +521,7 @@ sub __extract_license {
'GNU Free Documentation license' => 'unrestricted', 1,
'GNU Affero General Public License' => 'open_source', 1,
'(?:Free)?BSD license' => 'bsd', 1,
+ 'Artistic license 2\.0' => 'artistic_2', 1,
'Artistic license' => 'artistic', 1,
'Apache (?:Software )?license' => 'apache', 1,
'GPL' => 'gpl', 1,
@@ -550,9 +557,9 @@ sub license_from {
sub _extract_bugtracker {
my @links = $_[0] =~ m#L<(
- \Qhttp://rt.cpan.org/\E[^>]+|
- \Qhttp://github.com/\E[\w_]+/[\w_]+/issues|
- \Qhttp://code.google.com/p/\E[\w_\-]+/issues/list
+ https?\Q://rt.cpan.org/\E[^>]+|
+ https?\Q://github.com/\E[\w_]+/[\w_]+/issues|
+ https?\Q://code.google.com/p/\E[\w_\-]+/issues/list
)>#gx;
my %links;
@links{@links}=();
@@ -581,7 +588,7 @@ sub bugtracker_from {
sub requires_from {
my $self = shift;
my $content = Module::Install::_readperl($_[0]);
- my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg;
+ my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg;
while ( @requires ) {
my $module = shift @requires;
my $version = shift @requires;
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.99';
+ $VERSION = '1.08';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.99';
+ $VERSION = '1.08';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.99';
+ $VERSION = '1.08';
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
@@ -31,7 +31,7 @@ BEGIN {
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
- $VERSION = '0.99';
+ $VERSION = '1.08';
# Storage for the pseudo-singleton
$MAIN = undef;
@@ -230,8 +230,12 @@ sub preload {
sub new {
my ($class, %args) = @_;
- delete $INC{'FindBin.pm'};
- require FindBin;
+ delete $INC{'FindBin.pm'};
+ {
+ # to suppress the redefine warning
+ local $SIG{__WARN__} = sub {};
+ require FindBin;
+ }
# ignore the prefix on extension modules built from top level.
my $base_path = Cwd::abs_path($FindBin::Bin);
@@ -447,7 +451,7 @@ sub _version ($) {
}
sub _cmp ($$) {
- _version($_[0]) <=> _version($_[1]);
+ _version($_[1]) <=> _version($_[2]);
}
# Cloned from Params::Util::_CLASS
@@ -463,4 +467,4 @@ sub _CLASS ($) {
1;
-# Copyright 2008 - 2010 Adam Kennedy.
+# Copyright 2008 - 2012 Adam Kennedy.
@@ -4,12 +4,13 @@ use strict;
use warnings;
use re 'eval';
-use Digest::MD5 qw(md5_hex);
-use Encode qw();
-use Carp qw(croak);
-use base qw(Text::Markdown);
+use Digest::MD5 qw(md5_hex);
+use Encode qw();
+use Carp qw(croak);
+use base qw(Text::Markdown);
+use HTML::Entities qw(encode_entities);
-our $VERSION = '1.000034'; # 1.0.34
+our $VERSION = '1.000035'; # 1.0.34
$VERSION = eval $VERSION;
our @EXPORT_OK = qw(markdown);
@@ -53,7 +54,7 @@ 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 (C<< <div> >>, C<< <table> >> etc.). Note that by default
Markdown isn't interpreted in HTML block-level elements, unless you add
-a C<markdown=1"> attribute to the element. See L<Text::Markdown> for
+a C<markdown=1"> attribute to the element. See L<Text::Markdown> for
details.
This module implements the MultiMarkdown markdown syntax extensions from:
@@ -150,6 +151,8 @@ Metadata options supported are:
=item base_url
+=item self_url - The document url is prepended to the "#" anchor of footnotes.
+
=back
=head1 METADATA
@@ -228,6 +231,8 @@ sub new {
$p{bibliography_title} ||= 'Bibliography'; # FIXME - Test and document, can also be in metadata!
+ $p{self_url} ||= ''; # Used in footnotes to prepend anchors
+
my $self = { params => \%p };
bless $self, ref($class) || $class;
return $self;
@@ -757,10 +762,10 @@ sub _DoFootnotes {
if (defined $self->{_footnotes}{$id} ) {
$footnote_counter++;
if ($self->{_footnotes}{$id} =~ /^glossary:/i) {
- $result = qq{<a href="#fn:$id" id="fnref:$id" class="footnote glossary">$footnote_counter</a>};
+ $result = qq{<a href="$self->{self_url}#fn:$id" id="fnref:$id" class="footnote glossary">$footnote_counter</a>};
}
else {
- $result = qq{<a href="#fn:$id" id="fnref:$id" class="footnote">$footnote_counter</a>};
+ $result = qq{<a href="$self->{self_url}#fn:$id" id="fnref:$id" class="footnote">$footnote_counter</a>};
}
push (@{ $self->{_used_footnotes} }, $id);
}
@@ -810,10 +815,10 @@ sub _PrintFootnotes {
$glossary . q{:<p>};
}egsx;
- $result .= qq{<li id="fn:$id">$footnote<a href="#fnref:$id" class="reversefootnote"> ↩</a>$footnote_closing_tag</li>\n\n};
+ $result .= qq{<li id="fn:$id">$footnote<a href="$self->{self_url}#fnref:$id" class="reversefootnote"> ↩</a>$footnote_closing_tag</li>\n\n};
}
else {
- $result .= qq{<li id="fn:$id">$footnote<a href="#fnref:$id" class="reversefootnote"> ↩</a>$footnote_closing_tag</li>\n\n};
+ $result .= qq{<li id="fn:$id">$footnote<a href="$self->{self_url}#fnref:$id" class="reversefootnote"> ↩</a>$footnote_closing_tag</li>\n\n};
}
}
@@ -857,7 +862,7 @@ sub _xhtmlMetaData {
foreach my $key (sort keys %{$self->{_metadata}} ) {
if (lc($key) eq "title") {
- $result.= "\t\t<title>$self->{_metadata}{$key}</title>\n";
+ $result.= "\t\t<title>" . encode_entities($self->{_metadata}{$key}) . "</title>\n";
}
elsif (lc($key) eq "css") {
$result.= qq[\t\t<link type="text/css" rel="stylesheet" href="$self->{_metadata}{$key}"$self->{empty_element_suffix}\n];
@@ -866,7 +871,8 @@ sub _xhtmlMetaData {
$result .= qq[\t\t$self->{_metadata}{$key}\n]
}
else {
- $result.= qq[\t\t<meta name="$key" content="$self->{_metadata}{$key}"$self->{empty_element_suffix}\n];
+ $result.= qq[\t\t<meta name="] . encode_entities($key) . qq[" ]
+ . qq[content="] . encode_entities($self->{_metadata}{$key}) . qq["$self->{empty_element_suffix}\n];
}
}
$result.= "\t</head>\n";
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+use_ok( 'Text::MultiMarkdown');
+
+my $instr = <<TXT;
+A trivial block[^block] of text with footnote containing self_url.
+
+[^block]: See http://example.com
+
+TXT
+
+my $m = Text::MultiMarkdown->new(
+ self_url => 'self_url.html',
+);
+my $outstr = <<TXT;
+<p>A trivial block<a href="self_url.html#fn:block" id="fnref:block" class="footnote">1</a> of text with footnote containing self_url.</p>
+
+<div class="footnotes">
+<hr />
+<ol>
+
+<li id="fn:block"><p>See http://example.com<a href="self_url.html#fnref:block" class="reversefootnote"> ↩</a></p></li>
+
+</ol>
+</div>
+TXT
+
+is(
+ $m->markdown($instr) => $outstr,
+ 'Markdown with self_url footnotes'
+);
@@ -1,5 +1,6 @@
-Title: MultiMarkdown Test Document
-Author: Fletcher T. Penney, MD
+Title: MultiMarkdown Test & Document
+Author: Fletcher T. Penney, MD & others
+Email: John "Bull" Doe <john.bull.doe@example.org>
Date: January 14, 2006
Format: complete
Css: http://some.url/sample.css
@@ -1,11 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
- <meta name="Author" content="Fletcher T. Penney, MD" />
+ <meta name="Author" content="Fletcher T. Penney, MD & others" />
<link type="text/css" rel="stylesheet" href="http://some.url/sample.css" />
<meta name="Date" content="January 14, 2006" />
+ <meta name="Email" content="John "Bull" Doe <john.bull.doe@example.org>" />
<meta name="Format" content="complete" />
- <title>MultiMarkdown Test Document</title>
+ <title>MultiMarkdown Test & Document</title>
<link rel="openid.server" href="http://www.myopenid.com/server" />
<link rel="openid.delegate" href="http://openid.org/example" />
</head>