[libcgi-emulate-psgi-perl] 17/20: Imported Upstream version 0.15
dom at earth.li
dom at earth.li
Sun Oct 5 09:22:50 UTC 2014
This is an automated email from the git hooks/post-receive script.
dom pushed a commit to branch master
in repository libcgi-emulate-psgi-perl.
commit 353ce13d9f9960a54515dc5b51b991b4a65b6247
Author: Dominic Hargreaves <dom at earth.li>
Date: Sat Apr 20 14:02:29 2013 +0100
Imported Upstream version 0.15
---
Changes | 3 +
META.yml | 8 +-
README.mkdn | 36 ++++----
inc/Module/Install.pm | 4 +-
inc/Module/Install/Base.pm | 2 +-
inc/Module/Install/Can.pm | 85 +++++++++++++++--
inc/Module/Install/Fetch.pm | 2 +-
inc/Module/Install/Include.pm | 2 +-
inc/Module/Install/Makefile.pm | 22 +++--
inc/Module/Install/Metadata.pm | 2 +-
inc/Module/Install/ReadmeFromPod.pm | 112 ++++++++++++++++++++---
inc/Module/Install/Win32.pm | 2 +-
inc/Module/Install/WriteAll.pm | 2 +-
inc/Pod/Markdown.pm | 178 +++++++++++++++++++++++++++++-------
lib/CGI/Emulate/PSGI.pm | 2 +-
15 files changed, 370 insertions(+), 92 deletions(-)
diff --git a/Changes b/Changes
index 796a4f4..6a42395 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+0.15 Fri Oct 19 15:09:17 PDT 2012
+ - Repackage with the latest Module::Install
+
0.14 Mon Oct 31 10:37:49 PDT 2011
- Fixed a bug where croak was not imported from Carp (ctfliblime)
diff --git a/META.yml b/META.yml
index 87e14eb..974ddb5 100644
--- a/META.yml
+++ b/META.yml
@@ -3,12 +3,12 @@ abstract: 'PSGI adapter for CGI'
author:
- 'Tokuhiro Matsuno <tokuhirom at cpan.org>'
build_requires:
- ExtUtils::MakeMaker: 6.62
+ ExtUtils::MakeMaker: 6.59
configure_requires:
- ExtUtils::MakeMaker: 6.62
+ ExtUtils::MakeMaker: 6.59
distribution_type: module
dynamic_config: 1
-generated_by: 'Module::Install version 1.04'
+generated_by: 'Module::Install version 1.06'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -23,4 +23,4 @@ requires:
perl: 5.8.0
resources:
license: http://dev.perl.org/licenses/
-version: 0.14
+version: 0.15
diff --git a/README.mkdn b/README.mkdn
index ba5d1a2..762e069 100644
--- a/README.mkdn
+++ b/README.mkdn
@@ -39,8 +39,8 @@ Alternatively, you can install and use [CGI::Compile](http://search.cpan.org/per
compiles your existing CGI scripts into a sub that is perfectly ready
to be converted to PSGI application using this module.
- my $sub = CGI::Compile->compile("/path/to/script.cgi");
- my $app = CGI::Emulate::PSGI->handler($sub);
+ my $sub = CGI::Compile->compile("/path/to/script.cgi");
+ my $app = CGI::Emulate::PSGI->handler($sub);
This will take care of assigning an unique namespace for each script
etc. See [CGI::Compile](http://search.cpan.org/perldoc?CGI::Compile) for details.
@@ -48,20 +48,20 @@ etc. See [CGI::Compile](http://search.cpan.org/perldoc?CGI::Compile) for details
You can also consider using [CGI::PSGI](http://search.cpan.org/perldoc?CGI::PSGI) but that would require you to
slightly change your code from:
- my $q = CGI->new;
- # ...
- print $q->header, $output;
+ my $q = CGI->new;
+ # ...
+ print $q->header, $output;
into:
- use CGI::PSGI;
+ use CGI::PSGI;
- my $app = sub {
- my $env = shift;
- my $q = CGI::PSGI->new($env);
- # ...
- return [ $q->psgi_header, [ $output ] ];
- };
+ my $app = sub {
+ my $env = shift;
+ my $q = CGI::PSGI->new($env);
+ # ...
+ return [ $q->psgi_header, [ $output ] ];
+ };
See [CGI::PSGI](http://search.cpan.org/perldoc?CGI::PSGI) for details.
@@ -69,20 +69,20 @@ See [CGI::PSGI](http://search.cpan.org/perldoc?CGI::PSGI) for details.
- handler
- my $app = CGI::Emulate::PSGI->handler($code);
+ my $app = CGI::Emulate::PSGI->handler($code);
Creates a PSGI application code reference out of CGI code reference.
-- emulate_environment
+- emulate\_environment
- my %env = CGI::Emulate::PSGI->emulate_environment($env);
+ my %env = CGI::Emulate::PSGI->emulate_environment($env);
Creates an environment hash out of PSGI environment hash. If your code
or framework just needs an environment variable emulation, use this
method like:
- local %ENV = (%ENV, CGI::Emulate::PSGI->emulate_environment($env));
- # run your application
+ local %ENV = (%ENV, CGI::Emulate::PSGI->emulate_environment($env));
+ # run your application
If you use `handler` method to create a PSGI environment hash, this
is automatically called in the created application.
@@ -105,4 +105,4 @@ LICENSE file included with this module.
# SEE ALSO
-[PSGI](http://search.cpan.org/perldoc?PSGI) [CGI::Compile](http://search.cpan.org/perldoc?CGI::Compile) [CGI::PSGI](http://search.cpan.org/perldoc?CGI::PSGI) [Plack](http://search.cpan.org/perldoc?Plack) [CGI::Parse::PSGI](http://search.cpan.org/perldoc?CGI::Parse::PSGI)
\ No newline at end of file
+[PSGI](http://search.cpan.org/perldoc?PSGI) [CGI::Compile](http://search.cpan.org/perldoc?CGI::Compile) [CGI::PSGI](http://search.cpan.org/perldoc?CGI::PSGI) [Plack](http://search.cpan.org/perldoc?Plack) [CGI::Parse::PSGI](http://search.cpan.org/perldoc?CGI::Parse::PSGI)
diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm
index c685ca4..4ecf46b 100644
--- a/inc/Module/Install.pm
+++ b/inc/Module/Install.pm
@@ -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 = '1.04';
+ $VERSION = '1.06';
# Storage for the pseudo-singleton
$MAIN = undef;
@@ -467,4 +467,4 @@ sub _CLASS ($) {
1;
-# Copyright 2008 - 2011 Adam Kennedy.
+# Copyright 2008 - 2012 Adam Kennedy.
diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm
index b520616..802844a 100644
--- a/inc/Module/Install/Base.pm
+++ b/inc/Module/Install/Base.pm
@@ -4,7 +4,7 @@ package Module::Install::Base;
use strict 'vars';
use vars qw{$VERSION};
BEGIN {
- $VERSION = '1.04';
+ $VERSION = '1.06';
}
# Suspend handler for "redefined" warnings
diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm
index a162ad4..22167b8 100644
--- a/inc/Module/Install/Can.pm
+++ b/inc/Module/Install/Can.pm
@@ -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 = '1.04';
+ $VERSION = '1.06';
@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
diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm
index a412576..bee0c4f 100644
--- a/inc/Module/Install/Fetch.pm
+++ b/inc/Module/Install/Fetch.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.04';
+ $VERSION = '1.06';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
diff --git a/inc/Module/Install/Include.pm b/inc/Module/Install/Include.pm
index dd001eb..8310e4c 100644
--- a/inc/Module/Install/Include.pm
+++ b/inc/Module/Install/Include.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.04';
+ $VERSION = '1.06';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm
index 035cef2..7052f36 100644
--- a/inc/Module/Install/Makefile.pm
+++ b/inc/Module/Install/Makefile.pm
@@ -8,7 +8,7 @@ use Fcntl qw/:flock :seek/;
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.04';
+ $VERSION = '1.06';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -215,13 +215,17 @@ 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.
@@ -411,4 +415,4 @@ sub postamble {
__END__
-#line 540
+#line 544
diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm
index 31c953e..58430f3 100644
--- a/inc/Module/Install/Metadata.pm
+++ b/inc/Module/Install/Metadata.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.04';
+ $VERSION = '1.06';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
diff --git a/inc/Module/Install/ReadmeFromPod.pm b/inc/Module/Install/ReadmeFromPod.pm
index 348531e..fb7075f 100644
--- a/inc/Module/Install/ReadmeFromPod.pm
+++ b/inc/Module/Install/ReadmeFromPod.pm
@@ -7,29 +7,119 @@ use warnings;
use base qw(Module::Install::Base);
use vars qw($VERSION);
-$VERSION = '0.12';
+$VERSION = '0.18';
sub readme_from {
my $self = shift;
return unless $self->is_admin;
- my $file = shift || $self->_all_from
+ # Input file
+ my $in_file = shift || $self->_all_from
or die "Can't determine file to make readme_from";
- my $clean = shift;
- print "Writing README from $file\n";
+ # Get optional arguments
+ my ($clean, $format, $out_file, $options);
+ my $args = shift;
+ if ( ref $args ) {
+ # Arguments are in a hashref
+ if ( ref($args) ne 'HASH' ) {
+ die "Expected a hashref but got a ".ref($args)."\n";
+ } else {
+ $clean = $args->{'clean'};
+ $format = $args->{'format'};
+ $out_file = $args->{'output_file'};
+ $options = $args->{'options'};
+ }
+ } else {
+ # Arguments are in a list
+ $clean = $args;
+ $format = shift;
+ $out_file = shift;
+ $options = \@_;
+ }
+
+ # Default values;
+ $clean ||= 0;
+ $format ||= 'txt';
+
+ # Generate README
+ print "readme_from $in_file to $format\n";
+ if ($format =~ m/te?xt/) {
+ $out_file = $self->_readme_txt($in_file, $out_file, $options);
+ } elsif ($format =~ m/html?/) {
+ $out_file = $self->_readme_htm($in_file, $out_file, $options);
+ } elsif ($format eq 'man') {
+ $out_file = $self->_readme_man($in_file, $out_file, $options);
+ } elsif ($format eq 'pdf') {
+ $out_file = $self->_readme_pdf($in_file, $out_file, $options);
+ }
- require Pod::Text;
- my $parser = Pod::Text->new();
- open README, '> README' or die "$!\n";
- $parser->output_fh( *README );
- $parser->parse_file( $file );
if ($clean) {
- $self->clean_files('README');
+ $self->clean_files($out_file);
}
+
return 1;
}
+
+sub _readme_txt {
+ my ($self, $in_file, $out_file, $options) = @_;
+ $out_file ||= 'README';
+ require Pod::Text;
+ my $parser = Pod::Text->new( @$options );
+ open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n";
+ $parser->output_fh( *$out_fh );
+ $parser->parse_file( $in_file );
+ close $out_fh;
+ return $out_file;
+}
+
+
+sub _readme_htm {
+ my ($self, $in_file, $out_file, $options) = @_;
+ $out_file ||= 'README.htm';
+ require Pod::Html;
+ Pod::Html::pod2html(
+ "--infile=$in_file",
+ "--outfile=$out_file",
+ @$options,
+ );
+ # Remove temporary files if needed
+ for my $file ('pod2htmd.tmp', 'pod2htmi.tmp') {
+ if (-e $file) {
+ unlink $file or warn "Warning: Could not remove file '$file'.\n$!\n";
+ }
+ }
+ return $out_file;
+}
+
+
+sub _readme_man {
+ my ($self, $in_file, $out_file, $options) = @_;
+ $out_file ||= 'README.1';
+ require Pod::Man;
+ my $parser = Pod::Man->new( @$options );
+ $parser->parse_from_file($in_file, $out_file);
+ return $out_file;
+}
+
+
+sub _readme_pdf {
+ my ($self, $in_file, $out_file, $options) = @_;
+ $out_file ||= 'README.pdf';
+ eval { require App::pod2pdf; }
+ or die "Could not generate $out_file because pod2pdf could not be found\n";
+ my $parser = App::pod2pdf->new( @$options );
+ $parser->parse_from_file($in_file);
+ open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n";
+ select $out_fh;
+ $parser->output;
+ select STDOUT;
+ close $out_fh;
+ return $out_file;
+}
+
+
sub _all_from {
my $self = shift;
return unless $self->admin->{extensions};
@@ -44,5 +134,5 @@ sub _all_from {
__END__
-#line 112
+#line 254
diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm
index 99d9631..eeaa3fe 100644
--- a/inc/Module/Install/Win32.pm
+++ b/inc/Module/Install/Win32.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.04';
+ $VERSION = '1.06';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm
index 86bb25e..85d8018 100644
--- a/inc/Module/Install/WriteAll.pm
+++ b/inc/Module/Install/WriteAll.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.04';
+ $VERSION = '1.06';
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
diff --git a/inc/Pod/Markdown.pm b/inc/Pod/Markdown.pm
index d77c354..adbdd85 100644
--- a/inc/Pod/Markdown.pm
+++ b/inc/Pod/Markdown.pm
@@ -1,14 +1,27 @@
#line 1
+# vim: set ts=4 sts=4 sw=4 expandtab smarttab:
+#
+# This file is part of Pod-Markdown
+#
+# This software is copyright (c) 2004 by Marcel Gruenauer.
+#
+# This is free software; you can redistribute it and/or modify it under
+# the same terms as the Perl 5 programming language system itself.
+#
use 5.008;
use strict;
use warnings;
package Pod::Markdown;
+{
+ $Pod::Markdown::VERSION = '1.320';
+}
BEGIN {
- $Pod::Markdown::VERSION = '1.110730';
+ $Pod::Markdown::AUTHORITY = 'cpan:RWSTAUNER';
}
# ABSTRACT: Convert POD to Markdown
use parent qw(Pod::Parser);
+use Pod::ParseLink (); # core
sub initialize {
my $self = shift;
@@ -37,20 +50,16 @@ sub as_markdown {
if ($args{with_meta}) {
@header = $parser->_build_markdown_head;
}
- join("\n" x 2, @header, @{$lines});
+ join("\n" x 2, @header, @{$lines}) . "\n";
}
sub _build_markdown_head {
my $parser = shift;
my $data = $parser->_private;
- my $paragraph = '';
- if (defined $data->{Title}) {
- $paragraph .= sprintf '[[meta title="%s"]]', $data->{Title};
- }
- if (defined $data->{Author}) {
- $paragraph .= "\n" . sprintf '[[meta author="%s"]]', $data->{Author};
- }
- return $paragraph;
+ return join "\n",
+ map { qq![[meta \l$_="$data->{$_}"]]! }
+ grep { defined $data->{$_} }
+ qw( Title Author );
}
sub _save {
@@ -83,9 +92,25 @@ sub _indent_text {
sub _clean_text {
my $text = $_[1];
my @trimmed = grep { $_; } split(/\n/, $text);
+
return wantarray ? @trimmed : join("\n", @trimmed);
}
+sub _escape {
+ local $_ = $_[1];
+
+ # do inline characters first
+ s/([][\\`*_#])/\\$1/g;
+
+ # escape unordered lists and blockquotes
+ s/^([-+*>])/\\$1/mg;
+
+ # escape dots that would wrongfully create numbered lists
+ s/^( (?:>\s+)? \d+ ) (\.\x20)/$1\\$2/xgm;
+
+ return $_;
+}
+
sub command {
my ($parser, $command, $paragraph, $line_num) = @_;
my $data = $parser->_private;
@@ -97,6 +122,7 @@ sub command {
if ($command =~ m{head(\d)}xms) {
my $level = $1;
+ $paragraph = $parser->_escape($paragraph);
$paragraph = $parser->interpolate($paragraph, $line_num);
# the headers never are indented
@@ -125,8 +151,9 @@ sub command {
$data->{Indent}--;
$data->{searching} = '';
} elsif ($command =~ m{item}xms) {
- $paragraph = $parser->interpolate($paragraph, $line_num);
- $paragraph =~ s{^\h* \* \h*}{}xms;
+ # this strips the POD bullet; the searching=listhead will insert markdown's
+ # FIXME: this does not account for numbered or named lists
+ $paragraph =~ s{^[ \t]* \* [ \t]*}{}xms;
if ($data->{searching} eq 'listpara') {
$data->{searching} = 'listheadhuddled';
@@ -146,14 +173,49 @@ sub command {
sub verbatim {
my ($parser, $paragraph) = @_;
+
+ # NOTE: perlpodspec says parsers should expand tabs by default
+ # NOTE: Apparently Pod::Parser does not. should we?
+ # NOTE: this might be s/^\t/" " x 8/e, but what about tabs inside the para?
+
+ # POD verbatim can start with any number of spaces (or tabs)
+ # markdown should be 4 spaces (or a tab)
+ # so indent any paragraphs so that all lines start with at least 4 spaces
+ my @lines = split /\n/, $paragraph;
+ my $indent = ' ' x 4;
+ foreach my $line ( @lines ){
+ next unless $line =~ m/^( +)/;
+ # find the smallest indentation
+ $indent = $1 if length($1) < length($indent);
+ }
+ if( (my $smallest = length($indent)) < 4 ){
+ # invert to get what needs to be prepended
+ $indent = ' ' x (4 - $smallest);
+ # leave tabs alone
+ $paragraph = join "\n", map { /^\t/ ? $_ : $indent . $_ } @lines;
+ }
+
$parser->_save($paragraph);
}
+sub _escape_non_code {
+ my ($parser, $text, $ptree) = @_;
+ $text = $parser->_escape($text)
+ unless $ptree->isa('Pod::InteriorSequence') && $ptree->cmd_name eq 'C';
+ return $text;
+}
+
sub textblock {
my ($parser, $paragraph, $line_num) = @_;
my $data = $parser->_private;
- # interpolate the paragraph for embebed sequences
+ # escape markdown characters in text sequences except for inline code
+ $paragraph = join '', $parser->parse_text(
+ { -expand_text => '_escape_non_code' },
+ $paragraph, $line_num
+ )->raw_text;
+
+ # interpolate the paragraph for embedded sequences
$paragraph = $parser->interpolate($paragraph, $line_num);
# clean the empty lines
@@ -167,6 +229,8 @@ sub textblock {
my $is_huddled = $1;
$paragraph = sprintf '%s %s', $data->{ListType}, $paragraph;
if ($is_huddled) {
+ # FIXME: what does this do?
+ # does this have something to do with preserving an indent?
$paragraph = $parser->_unsave() . "\n" . $paragraph;
}
$data->{searching} = 'listpara';
@@ -179,48 +243,92 @@ sub textblock {
}
sub interior_sequence {
- my ($seq_command, $seq_argument, $pod_seq) = @_[1..3];
+ my ($self, $seq_command, $seq_argument, $pod_seq) = @_;
+
+ # nested links are not allowed
+ return sprintf '%s<%s>', $seq_command, $seq_argument
+ if $seq_command eq 'L' && $self->_private->{InsideLink};
+
+ my $i = 2;
my %interiors = (
- 'I' => sub { return '_' . $_[1] . '_' }, # italic
- 'B' => sub { return '__' . $_[1] . '__' }, # bold
- 'C' => sub { return '`' . $_[1] . '`' }, # monospace
- 'F' => sub { return '`' . $_[1] . '`' }, # system path
- 'S' => sub { return '`' . $_[1] . '`' }, # code
+ 'I' => sub { return '_' . $_[$i] . '_' }, # italic
+ 'B' => sub { return '__' . $_[$i] . '__' }, # bold
+ 'C' => sub { return '`' . $_[$i] . '`' }, # monospace
+ 'F' => sub { return '`' . $_[$i] . '`' }, # system path
+ # non-breaking space
+ 'S' => sub {
+ (my $s = $_[$i]) =~ s/ / /g;
+ return $s;
+ },
'E' => sub {
- my $charname = $_[1];
+ my $charname = $_[$i];
return '<' if $charname eq 'lt';
return '>' if $charname eq 'gt';
return '|' if $charname eq 'verbar';
return '/' if $charname eq 'sol';
+
+ # convert legacy charnames to more modern ones (see perlpodspec)
+ $charname =~ s/\A([lr])chevron\z/${1}aquo/;
+
+ return "&#$1;" if $charname =~ /^0(x[0-9a-fA-Z]+)$/;
+
+ $charname = oct($charname) if $charname =~ /^0\d+$/;
+
+ return "&#$charname;" if $charname =~ /^\d+$/;
+
return "&$charname;";
},
'L' => \&_resolv_link,
+ 'X' => sub { '' },
+ 'Z' => sub { '' },
);
if (exists $interiors{$seq_command}) {
my $code = $interiors{$seq_command};
- return $code->($seq_command, $seq_argument, $pod_seq);
+ return $code->($self, $seq_command, $seq_argument, $pod_seq);
} else {
return sprintf '%s<%s>', $seq_command, $seq_argument;
}
}
sub _resolv_link {
- my ($cmd, $arg) = @_;
- my $text = $arg =~ s"^(.+?)\|"" ? $1 : '';
-
- if ($arg =~ m{^http|ftp}xms) { # direct link to a URL
- $text ||= $arg;
- return sprintf '[%s](%s)', $text, $arg;
- } elsif ($arg =~ m{^/(.*)$}) {
- $text ||= $1;
- $text = $1;
- return "[$text](\#pod_$1)";
- } elsif ($arg =~ m{^(\w+(?:::\w+)*)$}) {
- $text ||= $1;
- return "[$text](http://search.cpan.org/perldoc?$1)";
+ my ($self, $cmd, $arg) = @_;
+
+ local $self->_private->{InsideLink} = 1;
+
+ my ($text, $inferred, $name, $section, $type) =
+ # perlpodspec says formatting codes can occur in all parts of an L<>
+ map { $_ && $self->interpolate($_, 1) }
+ Pod::ParseLink::parselink($arg);
+ my $url = '';
+
+ # TODO: make url prefixes configurable
+
+ if ($type eq 'url') {
+ $url = $name;
+ } elsif ($type eq 'man') {
+ # stolen from Pod::Simple::(X)HTML
+ my ($page, $part) = $name =~ /\A([^(]+)(?:[(](\S*)[)])?/;
+ $url = 'http://man.he.net/man' . ($part || 1) . '/' . ($page || $name);
} else {
+ if ($name) {
+ $url = 'http://search.cpan.org/perldoc?' . $name;
+ }
+ if ($section){
+ # TODO: sites/pod formatters differ on how to transform the section
+ # TODO: we could do it according to specified url prefix or pod formatter
+ # TODO: or allow a coderef?
+ # TODO: (Pod::Simple::XHTML:idify() for metacpan)
+ # TODO: (Pod::Simple::HTML section_escape/unicode_escape_url/section_url_escape for s.c.o.)
+ $url .= '#' . $section;
+ }
+ }
+
+ # if we don't know how to handle the url just print the pod back out
+ if (!$url) {
return sprintf '%s<%s>', $cmd, $arg;
}
+
+ return sprintf '[%s](%s)', ($text || $inferred), $url;
}
sub format_header {
@@ -232,5 +340,5 @@ sub format_header {
__END__
-#line 341
+#line 528
diff --git a/lib/CGI/Emulate/PSGI.pm b/lib/CGI/Emulate/PSGI.pm
index 5504966..c96bf48 100644
--- a/lib/CGI/Emulate/PSGI.pm
+++ b/lib/CGI/Emulate/PSGI.pm
@@ -8,7 +8,7 @@ use SelectSaver;
use Carp qw(croak);
use 5.00800;
-our $VERSION = '0.14';
+our $VERSION = '0.15';
sub handler {
my ($class, $code, ) = @_;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcgi-emulate-psgi-perl.git
More information about the Pkg-perl-cvs-commits
mailing list