Pod-Simple-Wiki-0.15/000755 000765 000024 00000000000 12036610111 014341 5ustar00Johnstaff000000 000000 Pod-Simple-Wiki-0.15/bin/000755 000765 000024 00000000000 12036610111 015111 5ustar00Johnstaff000000 000000 Pod-Simple-Wiki-0.15/Changes000644 000765 000024 00000004035 12036573666 015665 0ustar00Johnstaff000000 000000 Revision history for Pod::Simple::Wiki. 0.15 MMMM DD 2011 + Added options for beautifying MediaWiki output. Changes provided by Peter Hallam. + Added rudimentary link support to Confluence. 0.14 Sept 17 2010 ! Fix for RT#37480. Allow the output encoding to be specified by the --encoding pod2wiki option. 0.13 Aug 24 2010 ! Fix for RT#60650: Escape TiddlyWiki words. Patch by Olivier 'dolmen' Mengue'. 0.12 Aug 22 2010 ! Fix for RT#60304: Escape TiddlyWiki format sequences. Patch by Olivier 'dolmen' Mengue'. ! Fix for RT#60307: Ignore X<>. Patch by Olivier 'dolmen' Mengue'. 0.11 Aug 29 2009 ! Fix for literal newline in
 block in Textile filter.


0.10 Aug 28 2009

     + Added Textile support for github wikis.


0.09 May 24 2008

    + Added Confluence support.
      Thanks to David Bartle, Andrew Hobbs and
      Jim Renwick for patches.


0.08 August 25 2007

    + Added TiddlyWiki support.
      Thanks Tim Bunce and Ron Savage.

    + Added better MediaWiki support and tests.
      Thanks Christopher J. Madsen.


0.07 February 1 2007

    + Refactored format handlers into separate modules
      to make them easier to port and test.

    + Added Pod::Simple::Wiki::Template as an example
      of how to port a format.


0.06 January 30 2007

    + Added MoinMoin support (Michael Matthews)


0.05 March 30 2005

    + Added support for TWiki formatting (Sam Tregar)

    + Added support for Wikipedia formatting (Tony Sidaway)

    ! Updated to the new C2 Wiki bullet list format.

    + Added more tests.


0.04 August 24 2004

    ! Fixed bug when parsing F<> formats.
      Reported by Markus Dreyer.

    ! Fixed bug in kwiki h4 directives.

    + Added tests for formats and headings.

    + Added pod2wiki command line utility.


0.03 July 21 2003

    + First CPAN release.

    + Added usemod support.


0.02 May 21 2003

	+ First release to pod+people mailing list.

    + Added Kwiki support.


0.01 May 21 2003

	+ Initial version.

    + c2wiki support.


Pod-Simple-Wiki-0.15/examples/000755 000765 000024 00000000000 12036610111 016157 5ustar00Johnstaff000000 000000 Pod-Simple-Wiki-0.15/lib/000755 000765 000024 00000000000 12036610111 015107 5ustar00Johnstaff000000 000000 Pod-Simple-Wiki-0.15/Makefile.PL000644 000765 000024 00000001733 12036610010 016315 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w

use ExtUtils::MakeMaker;
use strict;

require 5.008;

my %deps = (
        'Pod::Simple'  => 0,
);

my %resources = (
    homepage    => 'http://jmcnamara.github.com/pod-simple-wiki/',
    repository  => 'http://github.com/jmcnamara/pod-simple-wiki',
    bugtracker  => 'http://github.com/jmcnamara/pod-simple-wiki/issues',
);

my %params = (
    'AUTHOR'        => 'John McNamara (jmcnamara@cpan.org)',
    'NAME'          => 'Pod::Simple::Wiki',
    'ABSTRACT_FROM' => 'lib/Pod/Simple/Wiki.pm',
    'VERSION_FROM'  => 'lib/Pod/Simple/Wiki.pm',
    'NEEDS_LINKING' => 0,
    'dist'          => { COMPRESS => 'gzip --best', SUFFIX => 'gz' },
    'EXE_FILES'     => ['bin/pod2wiki'],
    'LICENSE'       => 'perl',
    'PREREQ_PM'     => \%deps,
);

if ( $ExtUtils::MakeMaker::VERSION ge '6.46' ) {
    $params{META_MERGE} = { resources => \%resources };
}

if ( $ExtUtils::MakeMaker::VERSION ge '6.30_01' ) {
    $params{LICENSE} = 'perl';
}

WriteMakefile(%params);
Pod-Simple-Wiki-0.15/MANIFEST000644 000765 000024 00000002724 12036610111 015477 0ustar00Johnstaff000000 000000 Changes
MANIFEST
Makefile.PL
README

lib/Pod/Simple/Wiki.pm
lib/Pod/Simple/Wiki/Kwiki.pm
lib/Pod/Simple/Wiki/Mediawiki.pm
lib/Pod/Simple/Wiki/Moinmoin.pm
lib/Pod/Simple/Wiki/Template.pm
lib/Pod/Simple/Wiki/Tiddlywiki.pm
lib/Pod/Simple/Wiki/Twiki.pm
lib/Pod/Simple/Wiki/Usemod.pm
lib/Pod/Simple/Wiki/Confluence.pm
lib/Pod/Simple/Wiki/Textile.pm

bin/pod2wiki

examples/pod2wiki.pl
examples/pod2wiki_simple.pl

t/00_00_load.t

t/01_01_wiki_format.t
t/01_02_wiki_head.t
t/01_03_wiki_lists.t

t/02_01_kwiki_format.t
t/02_01_kwiki_head.t
t/02_01_kwiki_lists.t

t/03_01_usemod_format.t
t/03_02_usemod_head.t
t/03_03_usemod_lists.t

t/04_01_twiki_format.t
t/04_02_twiki_head.t
t/04_03_twiki_lists.t

t/05_01_mediawiki_format.t
t/05_02_mediawiki_head.t
t/05_03_mediawiki_lists.t
t/05_04_mediawiki_links.t
t/05_05_mediawiki_custom_tags.t
t/05_06_mediawiki_transformer_lists.t
t/05_07_mediawiki_link_prefix.t
t/05_08_mediawiki_sentence_case_headers.t
t/05_09_mediawiki_remove_name_section.t

t/06_01_moinmoin_format.t
t/06_03_moinmoin_lists.t

t/07_01_tiddlywiki_format.t
t/07_02_tiddlywiki_head.t
t/07_03_tiddlywiki_lists.t
t/07_04_tiddlywiki_text.t

t/08_01_confluence_format.t
t/08_02_confluence_head.t
t/08_03_confluence_lists.t
t/08_04_confluence_links.t

t/09_01_textile_format.t
t/09_02_textile_head.t
t/09_03_textile_lists.t

META.yml                                 Module YAML meta-data (added by MakeMaker)
META.json                                Module JSON meta-data (added by MakeMaker)
Pod-Simple-Wiki-0.15/META.json000644 000765 000024 00000002231 12036610111 015760 0ustar00Johnstaff000000 000000 {
   "abstract" : "A class for creating Pod to Wiki filters.",
   "author" : [
      "John McNamara (jmcnamara@cpan.org)"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
      "version" : "2"
   },
   "name" : "Pod-Simple-Wiki",
   "no_index" : {
      "directory" : [
         "t",
         "inc"
      ]
   },
   "prereqs" : {
      "build" : {
         "requires" : {
            "ExtUtils::MakeMaker" : 0
         }
      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : 0
         }
      },
      "runtime" : {
         "requires" : {
            "Pod::Simple" : 0
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "bugtracker" : {
         "web" : "http://github.com/jmcnamara/pod-simple-wiki/issues"
      },
      "homepage" : "http://jmcnamara.github.com/pod-simple-wiki/",
      "repository" : {
         "url" : "http://github.com/jmcnamara/pod-simple-wiki"
      }
   },
   "version" : "0.15"
}
Pod-Simple-Wiki-0.15/META.yml000644 000765 000024 00000001272 12036610111 015614 0ustar00Johnstaff000000 000000 ---
abstract: 'A class for creating Pod to Wiki filters.'
author:
  - 'John McNamara (jmcnamara@cpan.org)'
build_requires:
  ExtUtils::MakeMaker: 0
configure_requires:
  ExtUtils::MakeMaker: 0
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: 1.4
name: Pod-Simple-Wiki
no_index:
  directory:
    - t
    - inc
requires:
  Pod::Simple: 0
resources:
  bugtracker: http://github.com/jmcnamara/pod-simple-wiki/issues
  homepage: http://jmcnamara.github.com/pod-simple-wiki/
  repository: http://github.com/jmcnamara/pod-simple-wiki
version: 0.15
Pod-Simple-Wiki-0.15/README000644 000765 000024 00000002626 12036603570 015242 0ustar00Johnstaff000000 000000 NAME
    Pod::Simple::Wiki - A class for creating Pod to Wiki filters.


DESCRIPTION
    The `Pod::Simple::Wiki' module is used for converting Pod text
    to Wiki text.

    Pod (Plain Old Documentation) is a simple markup language used
    for writing Perl documentation.

    A Wiki is a user extensible web site. It uses very simple mark-
    up that is converted to Html.

    For an introduction to Wikis see: http://en.wikipedia.org/wiki/Wiki


SYNOPSIS
    To create a simple `pod2wiki' filter:

        #!/usr/bin/perl

        use strict;
        use warnings;
        use Pod::Simple::Wiki;

        my $parser = Pod::Simple::Wiki->new();

        if ( defined $ARGV[0] ) {
            open IN, $ARGV[0] or die "Couldn't open $ARGV[0]: $!\n";
        }
        else {
            *IN = *STDIN;
        }

        if ( defined $ARGV[1] ) {
            open OUT, ">$ARGV[1]" or die "Couldn't open $ARGV[1]: $!\n";
        }
        else {
            *OUT = *STDOUT;
        }

        $parser->output_fh( *OUT );
        $parser->parse_file( *IN );

        __END__


SEE ALSO
    This module also installs a `pod2wiki' command line utility. See
    `pod2wiki --help' for details.


AUTHOR
    John McNamara jmcnamara@cpan.org


COPYRIGHT
    © MMIII-MMXII, John McNamara.

    All Rights Reserved. This module is free software. It may be
    used, redistributed and/or modified under the same terms as Perl
    itself.
Pod-Simple-Wiki-0.15/t/000755 000765 000024 00000000000 12036610111 014604 5ustar00Johnstaff000000 000000 Pod-Simple-Wiki-0.15/t/00_00_load.t000644 000765 000024 00000000612 12036566301 016520 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w

###############################################################################
#
# A test for Pod::Simple::Wiki.
#
# Test that the module loads.
#
# reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org
#

use strict;

use Test::More tests => 2;

BEGIN { use_ok( 'Pod::Simple::Wiki' ); }

my $parser = Pod::Simple::Wiki->new;
isa_ok( $parser, 'Pod::Simple::Wiki' );
Pod-Simple-Wiki-0.15/t/01_01_wiki_format.t000644 000765 000024 00000003671 12036566301 020126 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w

###############################################################################
#
# A test for Pod::Simple::Wiki.
#
# Tests for I<>, B<>, C<> etc., formatting codes.
#
# reverse('©'), December 2005, John McNamara, jmcnamara@cpan.org
#


use strict;

use Pod::Simple::Wiki;
use Test::More tests => 6;

my $style = 'wiki';

# Output the tests for visual testing in the wiki.
# END{output_tests()};

my @tests  = (
                # Simple formatting tests
                [ "=pod\n\nI"      => qq(''Foo''\n\n),       'Italic'     ],
                [ "=pod\n\nB"      => qq('''Foo'''\n\n),     'Bold'       ],
                [ "=pod\n\nC"      => qq("Foo"\n\n),         'Monospace'  ],
                [ "=pod\n\nF"      => qq(''Foo''\n\n),       'Filename'   ],

                # Nested formatting tests
                [ "=pod\n\nB>"   => qq('''''Foo'''''\n\n), 'Bold Italic'],
                [ "=pod\n\nI>"   => qq('''''Foo'''''\n\n), 'Italic Bold'],
);



###############################################################################
#
#  Run the tests.
#
for my $test_ref (@tests) {

    my $parser  = Pod::Simple::Wiki->new($style);
    my $pod     = $test_ref->[0];
    my $target  = $test_ref->[1];
    my $name    = $test_ref->[2];
    my $wiki;

    $parser->output_string(\$wiki);
    $parser->parse_string_document($pod);

    is($wiki, $target, "\tTesting: $name");
}


###############################################################################
#
# Output the tests for visual testing in the wiki.
#
sub output_tests {

    my $test = 1;

    print "\n\n";

    for my $test_ref (@tests) {

        my $parser  =  Pod::Simple::Wiki->new($style);
        my $pod     =  $test_ref->[0];
        my $name    =  $test_ref->[2];

        $pod        =~ s/=pod\n\n//;
        $pod        = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod";

        $parser->parse_string_document($pod);
    }
}


__END__

Pod-Simple-Wiki-0.15/t/01_02_wiki_head.t000644 000765 000024 00000003673 12036566301 017542 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w

###############################################################################
#
# A test for Pod::Simple::Wiki.
#
# Tests for =head pod directives.
#
# reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org
#


use strict;

use Pod::Simple::Wiki;
use Test::More tests => 4;

my $style = 'wiki';

# Output the tests for visual testing in the wiki.
# END{output_tests()};

my @tests  = (
                [ "=pod\n\n=head1 Head 1" => qq(\n----\n'''Head 1'''\n\n)],
                [ "=pod\n\n=head2 Head 2" => qq(\n'''''Head 2'''''\n\n)  ],
                [ "=pod\n\n=head3 Head 3" => qq(\n''Head 3''\n\n)        ],
                [ "=pod\n\n=head4 Head 4" => qq(\nHead 4\n\n)            ],
             );




###############################################################################
#
#  Run the tests.
#
for my $test_ref (@tests) {

    my $parser  = Pod::Simple::Wiki->new($style);
    my $pod     = $test_ref->[0];
    my $target  = $test_ref->[1];
    my $wiki;

    $parser->output_string(\$wiki);
    $parser->parse_string_document($pod);


    is($wiki, $target, "\tTesting: " . encode_escapes($pod));
}


###############################################################################
#
# Encode escapes to make them visible in the test output.
#
sub encode_escapes {
    my $data = $_[0];

    for ($data) {
        s/\t/\\t/g;
        s/\n/\\n/g;
    }

    return $data;
}


###############################################################################
#
# Output the tests for visual testing in the wiki.
#
sub output_tests {

    my $test = 1;

    print "\n----\n\n";

    for my $test_ref (@tests) {

        my $parser  =  Pod::Simple::Wiki->new($style);
        my $pod     =  $test_ref->[0];
        my $pod2    =  encode_escapes($pod);
           $pod2    =~ s/^=pod\\n\\n//;

        print "Test ", $test++, ":\t", $pod2, "\n";
        $parser->parse_string_document($pod);
        print "\n----\n\n";
    }
}

__END__



Pod-Simple-Wiki-0.15/t/01_03_wiki_lists.t000644 000765 000024 00000015255 12036566301 017777 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w

###############################################################################
#
# A test for Pod::Simple::Wiki.
#
# Tests for =over ... =back regions.
#
# reverse('©'), March 2005, John McNamara, jmcnamara@cpan.org
#


use strict;

use Pod::Simple::Wiki;
use Test::More tests => 12;

my $style = 'wiki';

# Output the tests for visual testing in the wiki.
# END{output_tests()};

my @tests;

#
# Extract tests embedded in _DATA_ section.
#
my $test_no = 1;
my $pod;
my $test = '';
my $todo = '';;
my $name;

while () {
    if (/^#/) {
        $name = $1 if /NAME: (.*)/;
        $todo = $1 if /TODO: (.*)/;

        if ($test) {
            if ($test_no % 2) {
                $pod = $test;
            }
            else {
                push @tests, [$pod, $test, $name, $todo];
                $name = '';
                $todo = '';
            }

            $test = '';
            $test_no++;
        }
        next;
    }
    s/\r//;     # Remove any \r chars that slip in.
    s/\\t/\t/g; # Sub back in any escaped tabs.
    s/\\#/#/g;  # Sub back in any escaped comments.
    $test .= $_;
}


###############################################################################
#
#  Run the tests.
#
for my $test_ref (@tests) {

    my $parser  = Pod::Simple::Wiki->new($style);
    my $pod     = $test_ref->[0];
    my $target  = $test_ref->[1];
    my $name    = $test_ref->[2];
    my $todo    = $test_ref->[3];
    my $wiki;

    $parser->output_string(\$wiki);
    $parser->parse_string_document($pod);

    local $TODO = $todo;
    is($wiki, $target, " \t" . $name);
}


###############################################################################
#
# Output the tests for visual testing in the wiki.
#
sub output_tests {

    my $test = 1;

    print "\n----\n\n";

    for my $test_ref (@tests) {

        my $parser  =  Pod::Simple::Wiki->new($style);
        my $pod     =  $test_ref->[0];
        my $name    =  $test_ref->[2];

        print "Test ", $test++, ":\t", $name, "\n";
        $parser->parse_string_document($pod);
        print "\n----\n\n";
    }
}

__DATA__
################################################################################
#
# Test data.
#
################################################################################
#
# NAME: Test for single unordered (bullet) item.
#
=pod

=over

=item *

Bullet item

=back

=cut
#
#
# Expected output.
#
#
*Bullet item

################################################################################
#
# NAME: Test for unordered (bullet) list, 
    . # =pod =over =item * Bullet item 1.0 =item * Bullet item 2.0 =item * Bullet item 3.0 =back =cut # # # Expected output. # # *Bullet item 1.0 *Bullet item 2.0 *Bullet item 3.0 ############################################################################### # # NAME: Test for nested unordered (bullet) list,
      . # =pod =over =item * Bullet item 1.0 =over =item * Bullet item 1.1 =over =item * Bullet item 1.2 =item * Bullet item 2.2 =back =item * Bullet item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # *Bullet item 1.0 **Bullet item 1.1 ***Bullet item 1.2 ***Bullet item 2.2 **Bullet item 2.1 *Bullet item 2.0 ################################################################################ # # NAME: Test for single ordered (number) item. # =pod =over =item 1 Number item =back =cut # # # Expected output. # # \t1Number item ############################################################################### # # NAME: Test for ordered (number) list,
        . # =pod =over =item 1 Number item 1.0 =item 2 Number item 2.0 =item 3 Number item 3.0 =back =cut # # # Expected output. # # \t1Number item 1.0 \t2Number item 2.0 \t3Number item 3.0 ############################################################################### # # NAME: Test for nested ordered (number) list,
          . # =pod =over =item 1 Number item 1.0 =over =item 1 Number item 1.1 =over =item 1 Number item 1.2 =item 2 Number item 2.2 =back =item 2 Number item 2.1 =back =item 2 Number item 2.0 =back =cut # # # Expected output. # # \t1Number item 1.0 \t\t1Number item 1.1 \t\t\t1Number item 1.2 \t\t\t2Number item 2.2 \t\t2Number item 2.1 \t2Number item 2.0 ################################################################################ # # NAME: Test for single definition list item. # =pod =over =item Foo Definition item =back =cut # # # Expected output. # # \tFoo:\tDefinition item ############################################################################### # # NAME: Test for definition list,
          . # =pod =over =item Foo Definition item 1.0 =item Bar Definition item 2.0 =item Baz Definition item 3.0 =back =cut # # # Expected output. # # \tFoo:\tDefinition item 1.0 \tBar:\tDefinition item 2.0 \tBaz:\tDefinition item 3.0 ############################################################################### # # NAME: Test for nested definition list,
          . # =pod =over =item Foo Definition item 1.0 =over =item Foo Definition item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item Bar Definition item 2.1 =back =item Bar Definition item 2.0 =back =cut # # # Expected output. # # \tFoo:\tDefinition item 1.0 \t\tFoo:\tDefinition item 1.1 \t\t\tFoo:\tDefinition item 1.2 \t\t\tBar:\tDefinition item 2.2 \t\tBar:\tDefinition item 2.1 \tBar:\tDefinition item 2.0 ############################################################################### # # NAME: Test for varied nested list. # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # *Bullet item 1.0 \t\t1Number item 1.1 \t\t\tFoo:\tDefinition item 1.2 \t\t\tBar:\tDefinition item 2.2 \t\t2Number item 2.1 *Bullet item 2.0 ################################################################################ # # NAME: Test for definition list without =items,
          . # =pod =over This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # \t :\tThis is a long sentence that forms part of a definition block. ################################################################################ # # NAME: Test for definition list without a definition. # # TODO: Fix this later. # =pod =over =item This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # \tThis is a long sentence that forms part of a definition block.:\t ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/t/02_01_kwiki_format.t000644 000765 000024 00000003624 12036566301 020300 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for I<>, B<>, C<> etc., formatting codes. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 6; my $style = 'kwiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\nI" => qq(/Foo/\n\n), 'Italic' ], [ "=pod\n\nB" => qq(*Foo*\n\n), 'Bold' ], [ "=pod\n\nC" => qq([=Foo]\n\n), 'Monospace' ], [ "=pod\n\nF" => qq(/Foo/\n\n), 'Filename' ], # Nested formatting tests [ "=pod\n\nB>" => qq(*/Foo/*\n\n), 'Bold Italic'], [ "=pod\n\nI>" => qq(/*Foo*/\n\n), 'Italic Bold'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/02_01_kwiki_head.t000644 000765 000024 00000003664 12036566301 017715 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =head pod directives. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 4; my $style = 'kwiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( [ "=pod\n\n=head1 Head 1" => qq(\n----\n= Head 1 =\n\n)], [ "=pod\n\n=head2 Head 2" => qq(\n== Head 2 ==\n\n) ], [ "=pod\n\n=head3 Head 3" => qq(\n=== Head 3 ===\n\n) ], [ "=pod\n\n=head4 Head 4" => qq(==== Head 4\n\n) ], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: " . encode_escapes($pod)); } ############################################################################### # # Encode escapes to make them visible in the test output. # sub encode_escapes { my $data = $_[0]; for ($data) { s/\t/\\t/g; s/\n/\\n/g; } return $data; } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $pod2 = encode_escapes($pod); $pod2 =~ s/^=pod\\n\\n//; print "Test ", $test++, ":\t", $pod2, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __END__ Pod-Simple-Wiki-0.15/t/02_01_kwiki_lists.t000644 000765 000024 00000015263 12036566301 020150 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =over ... =back regions. # # reverse('©'), March 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 12; my $style = 'kwiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests; # # Extract tests embedded in _DATA_ section. # my $test_no = 1; my $pod; my $test = ''; my $todo = '';; my $name; while () { if (/^#/) { $name = $1 if /NAME: (.*)/; $todo = $1 if /TODO: (.*)/; if ($test) { if ($test_no % 2) { $pod = $test; } else { push @tests, [$pod, $test, $name, $todo]; $name = ''; $todo = ''; } $test = ''; $test_no++; } next; } s/\r//; # Remove any \r chars that slip in. s/\\t/\t/g; # Sub back in any escaped tabs. s/\\#/#/g; # Sub back in any escaped comments. $test .= $_; } ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, " \t" . $name); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; print "Test ", $test++, ":\t", $name, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __DATA__ ################################################################################ # # Test data. # ################################################################################ # # NAME: Test for single unordered (bullet) item. # =pod =over =item * Bullet item =back =cut # # # Expected output. # # * Bullet item ################################################################################ # # NAME: Test for unordered (bullet) list,
            . # =pod =over =item * Bullet item 1.0 =item * Bullet item 2.0 =item * Bullet item 3.0 =back =cut # # # Expected output. # # * Bullet item 1.0 * Bullet item 2.0 * Bullet item 3.0 ############################################################################### # # NAME: Test for nested unordered (bullet) list,
              . # =pod =over =item * Bullet item 1.0 =over =item * Bullet item 1.1 =over =item * Bullet item 1.2 =item * Bullet item 2.2 =back =item * Bullet item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 ** Bullet item 1.1 *** Bullet item 1.2 *** Bullet item 2.2 ** Bullet item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for single ordered (number) item. # =pod =over =item 1 Number item =back =cut # # # Expected output. # # 0 Number item ############################################################################### # # NAME: Test for ordered (number) list,
                . # =pod =over =item 1 Number item 1.0 =item 2 Number item 2.0 =item 3 Number item 3.0 =back =cut # # # Expected output. # # 0 Number item 1.0 0 Number item 2.0 0 Number item 3.0 ############################################################################### # # NAME: Test for nested ordered (number) list,
                  . # =pod =over =item 1 Number item 1.0 =over =item 1 Number item 1.1 =over =item 1 Number item 1.2 =item 2 Number item 2.2 =back =item 2 Number item 2.1 =back =item 2 Number item 2.0 =back =cut # # # Expected output. # # 0 Number item 1.0 00 Number item 1.1 000 Number item 1.2 000 Number item 2.2 00 Number item 2.1 0 Number item 2.0 ################################################################################ # # NAME: Test for single definition list item. # =pod =over =item Foo Definition item =back =cut # # # Expected output. # # ; Foo ; Definition item ############################################################################### # # NAME: Test for definition list,
                  . # =pod =over =item Foo Definition item 1.0 =item Bar Definition item 2.0 =item Baz Definition item 3.0 =back =cut # # # Expected output. # # ; Foo ; Definition item 1.0 ; Bar ; Definition item 2.0 ; Baz ; Definition item 3.0 ############################################################################### # # NAME: Test for nested definition list,
                  . # =pod =over =item Foo Definition item 1.0 =over =item Foo Definition item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item Bar Definition item 2.1 =back =item Bar Definition item 2.0 =back =cut # # # Expected output. # # ; Foo ; Definition item 1.0 ;; Foo ; Definition item 1.1 ;;; Foo ; Definition item 1.2 ;;; Bar ; Definition item 2.2 ;; Bar ; Definition item 2.1 ; Bar ; Definition item 2.0 ############################################################################### # # NAME: Test for varied nested list. # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 00 Number item 1.1 ;;; Foo ; Definition item 1.2 ;;; Bar ; Definition item 2.2 00 Number item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for definition list without =items,
                  . # # TODO: Fix this later. # =pod =over This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # ; ; This is a long sentence that forms part of a definition block. ################################################################################ # # NAME: Test for definition list without a definition. # # TODO: Fix this later. # =pod =over =item This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # ; This is a long sentence that forms part of a definition block. ; ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/t/03_01_usemod_format.t000644 000765 000024 00000003645 12036566301 020462 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for I<>, B<>, C<> etc., formatting codes. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 6; my $style = 'usemod'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\nI" => qq(Foo\n\n), 'Italic' ], [ "=pod\n\nB" => qq(Foo\n\n), 'Bold' ], [ "=pod\n\nC" => qq(Foo\n\n), 'Monospace' ], [ "=pod\n\nF" => qq(Foo\n\n), 'Filename' ], # Nested formatting tests [ "=pod\n\nB>" => qq(Foo\n\n), 'Bold Italic'], [ "=pod\n\nI>" => qq(Foo\n\n), 'Italic Bold'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/03_02_usemod_head.t000644 000765 000024 00000003665 12036566301 020076 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =head pod directives. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 4; my $style = 'usemod'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( [ "=pod\n\n=head1 Head 1" => qq(\n= Head 1 =\n\n) ], [ "=pod\n\n=head2 Head 2" => qq(\n== Head 2 ==\n\n) ], [ "=pod\n\n=head3 Head 3" => qq(\n=== Head 3 ===\n) ], [ "=pod\n\n=head4 Head 4" => qq(\n==== Head 4 ====\n\n)], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: " . encode_escapes($pod)); } ############################################################################### # # Encode escapes to make them visible in the test output. # sub encode_escapes { my $data = $_[0]; for ($data) { s/\t/\\t/g; s/\n/\\n/g; } return $data; } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $pod2 = encode_escapes($pod); $pod2 =~ s/^=pod\\n\\n//; print "Test ", $test++, ":\t", $pod2, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __END__ Pod-Simple-Wiki-0.15/t/03_03_usemod_lists.t000644 000765 000024 00000015201 12036566301 020321 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =over ... =back regions. # # reverse('©'), March 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 12; my $style = 'usemod'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests; # # Extract tests embedded in _DATA_ section. # my $test_no = 1; my $pod; my $test = ''; my $todo = '';; my $name; while () { if (/^#/) { $name = $1 if /NAME: (.*)/; $todo = $1 if /TODO: (.*)/; if ($test) { if ($test_no % 2) { $pod = $test; } else { push @tests, [$pod, $test, $name, $todo]; $name = ''; $todo = ''; } $test = ''; $test_no++; } next; } s/\r//; # Remove any \r chars that slip in. s/\\t/\t/g; # Sub back in any escaped tabs. s/\\#/#/g; # Sub back in any escaped comments. $test .= $_; } ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, " \t" . $name); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; print "Test ", $test++, ":\t", $name, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __DATA__ ################################################################################ # # Test data. # ################################################################################ # # NAME: Test for single unordered (bullet) item. # =pod =over =item * Bullet item =back =cut # # # Expected output. # # *Bullet item ################################################################################ # # NAME: Test for unordered (bullet) list,
                    . # =pod =over =item * Bullet item 1.0 =item * Bullet item 2.0 =item * Bullet item 3.0 =back =cut # # # Expected output. # # *Bullet item 1.0 *Bullet item 2.0 *Bullet item 3.0 ############################################################################### # # NAME: Test for nested unordered (bullet) list,
                      . # =pod =over =item * Bullet item 1.0 =over =item * Bullet item 1.1 =over =item * Bullet item 1.2 =item * Bullet item 2.2 =back =item * Bullet item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # *Bullet item 1.0 **Bullet item 1.1 ***Bullet item 1.2 ***Bullet item 2.2 **Bullet item 2.1 *Bullet item 2.0 ################################################################################ # # NAME: Test for single ordered (number) item. # =pod =over =item 1 Number item =back =cut # # # Expected output. # # \#Number item ############################################################################### # # NAME: Test for ordered (number) list,
                        . # =pod =over =item 1 Number item 1.0 =item 2 Number item 2.0 =item 3 Number item 3.0 =back =cut # # # Expected output. # # \#Number item 1.0 \#Number item 2.0 \#Number item 3.0 ############################################################################### # # NAME: Test for nested ordered (number) list,
                          . # =pod =over =item 1 Number item 1.0 =over =item 1 Number item 1.1 =over =item 1 Number item 1.2 =item 2 Number item 2.2 =back =item 2 Number item 2.1 =back =item 2 Number item 2.0 =back =cut # # # Expected output. # # \#Number item 1.0 \##Number item 1.1 \###Number item 1.2 \###Number item 2.2 \##Number item 2.1 \#Number item 2.0 ################################################################################ # # NAME: Test for single definition list item. # =pod =over =item Foo Definition item =back =cut # # # Expected output. # # ;Foo:Definition item ############################################################################### # # NAME: Test for definition list,
                          . # =pod =over =item Foo Definition item 1.0 =item Bar Definition item 2.0 =item Baz Definition item 3.0 =back =cut # # # Expected output. # # ;Foo:Definition item 1.0 ;Bar:Definition item 2.0 ;Baz:Definition item 3.0 ############################################################################### # # NAME: Test for nested definition list,
                          . # =pod =over =item Foo Definition item 1.0 =over =item Foo Definition item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item Bar Definition item 2.1 =back =item Bar Definition item 2.0 =back =cut # # # Expected output. # # ;Foo:Definition item 1.0 ;;Foo:Definition item 1.1 ;;;Foo:Definition item 1.2 ;;;Bar:Definition item 2.2 ;;Bar:Definition item 2.1 ;Bar:Definition item 2.0 ############################################################################### # # NAME: Test for varied nested list. # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # *Bullet item 1.0 \##Number item 1.1 ;;;Foo:Definition item 1.2 ;;;Bar:Definition item 2.2 \##Number item 2.1 *Bullet item 2.0 ################################################################################ # # NAME: Test for definition list without =items,
                          . # # TODO: Fix this later. # =pod =over This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # ; :This is a long sentence that forms part of a definition block. ################################################################################ # # NAME: Test for definition list without a definition. # # TODO: Fix this later. # =pod =over =item This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # ;This is a long sentence that forms part of a definition block.: ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/t/04_01_twiki_format.t000644 000765 000024 00000004051 12036566301 020306 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for I<>, B<>, C<> etc., formatting codes. # # reverse('©'), March 2005, Sam Tregar, sam@tregar.com # use strict; use Pod::Simple::Wiki; use Test::More tests => 6; my $style = 'twiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\nI" => qq(_Foo_\n\n), 'Italic' ], [ "=pod\n\nB" => qq(*Foo*\n\n), 'Bold' ], [ "=pod\n\nC" => qq(=Foo=\n\n), 'Monospace' ], [ "=pod\n\nF" => qq(_Foo_\n\n), 'Filename' ], # Nested formatting tests [ "=pod\n\nB>" => qq(*_Foo_*\n\n), 'Bold Italic' ], [ "=pod\n\nI>" => qq(__Foo__\n\n), 'Italic Bold', 'Fix this later.'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/04_02_twiki_head.t000644 000765 000024 00000003746 12036566301 017732 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =head pod directives. # # reverse('©'), March 2005, Sam Tregar, sam@tregar.com # use strict; use Pod::Simple::Wiki; use Test::More tests => 4; my $style = 'twiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( [ "=pod\n\n=head1 Head 1" => qq(---+ Head 1\n\n) ], [ "=pod\n\n=head2 Head 2" => qq(---++ Head 2\n\n) ], [ "=pod\n\n=head3 Head 3" => qq(---+++ Head 3\n\n) ], [ "=pod\n\n=head4 Head 4" => qq(---++++ Head 4\n\n) ], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: " . encode_escapes($pod)); } ############################################################################### # # Encode escapes to make them visible in the test output. # sub encode_escapes { my $data = $_[0]; for ($data) { s/\t/\\t/g; s/\n/\\n/g; } return $data; } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $pod2 = encode_escapes($pod); $pod2 =~ s/^=pod\\n\\n//; $pod2 =~ s//>/g; print "Test ", $test++, ":\t", $pod2, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __END__ Pod-Simple-Wiki-0.15/t/04_03_twiki_lists.t000644 000765 000024 00000015626 12036566301 020170 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =over ... =back regions. # # reverse('©'), March 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 12; my $style = 'twiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests; # # Extract tests embedded in _DATA_ section. # my $test_no = 1; my $pod; my $test = ''; my $todo = '';; my $name; while () { if (/^#/) { $name = $1 if /NAME: (.*)/; $todo = $1 if /TODO: (.*)/; if ($test) { if ($test_no % 2) { $pod = $test; } else { push @tests, [$pod, $test, $name, $todo]; $name = ''; $todo = ''; } $test = ''; $test_no++; } next; } s/\r//; # Remove any \r chars that slip in. s/\\t/\t/g; # Sub back in any escaped tabs. s/\\#/#/g; # Sub back in any escaped comments. $test .= $_; } ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, " \t" . $name); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $name =~ s[<][<]g; $name =~ s[>][>]g; print "Test ", $test++, ":\t", $name, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __DATA__ ################################################################################ # # Test data. # ################################################################################ # # NAME: Test for single unordered (bullet) item. # =pod =over =item * Bullet item =back =cut # # # Expected output. # # * Bullet item ################################################################################ # # NAME: Test for unordered (bullet) list,
                            . # =pod =over =item * Bullet item 1.0 =item * Bullet item 2.0 =item * Bullet item 3.0 =back =cut # # # Expected output. # # * Bullet item 1.0 * Bullet item 2.0 * Bullet item 3.0 ############################################################################### # # NAME: Test for nested unordered (bullet) list,
                              . # =pod =over =item * Bullet item 1.0 =over =item * Bullet item 1.1 =over =item * Bullet item 1.2 =item * Bullet item 2.2 =back =item * Bullet item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 * Bullet item 1.1 * Bullet item 1.2 * Bullet item 2.2 * Bullet item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for single ordered (number) item. # =pod =over =item 1 Number item =back =cut # # # Expected output. # # 1. Number item ############################################################################### # # NAME: Test for ordered (number) list,
                                . # =pod =over =item 1 Number item 1.0 =item 2 Number item 2.0 =item 3 Number item 3.0 =back =cut # # # Expected output. # # 1. Number item 1.0 2. Number item 2.0 3. Number item 3.0 ############################################################################### # # NAME: Test for nested ordered (number) list,
                                  . # =pod =over =item 1 Number item 1.0 =over =item 1 Number item 1.1 =over =item 1 Number item 1.2 =item 2 Number item 2.2 =back =item 2 Number item 2.1 =back =item 2 Number item 2.0 =back =cut # # # Expected output. # # 1. Number item 1.0 1. Number item 1.1 1. Number item 1.2 2. Number item 2.2 2. Number item 2.1 2. Number item 2.0 ################################################################################ # # NAME: Test for single definition list item. # =pod =over =item Foo Definition item =back =cut # # # Expected output. # # $ Foo: Definition item ############################################################################### # # NAME: Test for definition list,
                                  . # =pod =over =item Foo Definition item 1.0 =item Bar Definition item 2.0 =item Baz Definition item 3.0 =back =cut # # # Expected output. # # $ Foo: Definition item 1.0 $ Bar: Definition item 2.0 $ Baz: Definition item 3.0 ############################################################################### # # NAME: Test for nested definition list,
                                  . # =pod =over =item Foo Definition item 1.0 =over =item Foo Definition item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item Bar Definition item 2.1 =back =item Bar Definition item 2.0 =back =cut # # # Expected output. # # $ Foo: Definition item 1.0 $ Foo: Definition item 1.1 $ Foo: Definition item 1.2 $ Bar: Definition item 2.2 $ Bar: Definition item 2.1 $ Bar: Definition item 2.0 ############################################################################### # # NAME: Test for varied nested list. # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 1. Number item 1.1 $ Foo: Definition item 1.2 $ Bar: Definition item 2.2 2. Number item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for definition list without =items,
                                  . # # TODO: Fix this later. # =pod =over This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # : This is a long sentence that forms part of a definition block. ################################################################################ # # NAME: Test for definition list without a definition. # # TODO: Fix this later. # =pod =over =item This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # $ This is a long sentence that forms part of a definition block.: ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/t/05_01_mediawiki_format.t000644 000765 000024 00000004001 12036566301 021116 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for I<>, B<>, C<> etc., formatting codes. # # reverse('©'), December 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 7; my $style = 'mediawiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\nI" => qq(''Foo''\n\n), 'Italic' ], [ "=pod\n\nB" => qq('''Foo'''\n\n), 'Bold' ], [ "=pod\n\nC" => qq(Foo\n\n), 'Monospace' ], [ "=pod\n\nF" => qq(''Foo''\n\n), 'Filename' ], # Nested formatting tests [ "=pod\n\nB>" => qq('''''Foo'''''\n\n), 'Bold Italic'], [ "=pod\n\nI>" => qq('''''Foo'''''\n\n), 'Italic Bold'], # Character escaping [ "=pod\n\nThis is neither ''italic'' nor '''bold'''" => qq(This is neither ''italic'' nor '''bold'''\n\n), 'Single quotes' ], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/05_02_mediawiki_head.t000644 000765 000024 00000003634 12036566301 020543 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =head pod directives. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 4; my $style = 'mediawiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( [ "=pod\n\n=head1 Head 1" => qq(==Head 1==\n)], [ "=pod\n\n=head2 Head 2" => qq(===Head 2===\n)], [ "=pod\n\n=head3 Head 3" => qq(====Head 3====\n)], [ "=pod\n\n=head4 Head 4" => qq(=====Head 4=====\n)], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: " . encode_escapes($pod)); } ############################################################################### # # Encode escapes to make them visible in the test output. # sub encode_escapes { my $data = $_[0]; for ($data) { s/\t/\\t/g; s/\n/\\n/g; } return $data; } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $pod2 = encode_escapes($pod); $pod2 =~ s/^=pod\\n\\n//; print "Test ", $test++, ":\t", $pod2, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __END__ Pod-Simple-Wiki-0.15/t/05_03_mediawiki_lists.t000644 000765 000024 00000017250 12036566301 021000 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =over ... =back regions. # # reverse('©'), March 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 14; my $style = 'mediawiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests; # # Extract tests embedded in _DATA_ section. # my $test_no = 1; my $pod; my $test = ''; my $todo = '';; my $name; while () { if (/^#/) { $name = $1 if /NAME: (.*)/; $todo = $1 if /TODO: (.*)/; if ($test) { if ($test_no % 2) { $pod = $test; } else { push @tests, [$pod, $test, $name, $todo]; $name = ''; $todo = ''; } $test = ''; $test_no++; } next; } s/\r//; # Remove any \r chars that slip in. s/\\t/\t/g; # Sub back in any escaped tabs. s/\\#/#/g; # Sub back in any escaped comments. $test .= $_; } ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, " \t" . $name); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; print "Test ", $test++, ":\t", $name, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __DATA__ ################################################################################ # # Test data. # ################################################################################ # # NAME: Test for single unordered (bullet) item. # =pod =over =item * Bullet item =back =cut # # # Expected output. # # * Bullet item ################################################################################ # # NAME: Test for unordered (bullet) list,
                                    . # =pod =over =item * Bullet item 1.0 =item * Bullet item 2.0 =item * Bullet item 3.0 =back =cut # # # Expected output. # # * Bullet item 1.0 * Bullet item 2.0 * Bullet item 3.0 ############################################################################### # # NAME: Test for nested unordered (bullet) list,
                                      . # =pod =over =item * Bullet item 1.0 =over =item * Bullet item 1.1 =over =item * Bullet item 1.2 =item * Bullet item 2.2 =back =item * Bullet item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 ** Bullet item 1.1 *** Bullet item 1.2 *** Bullet item 2.2 ** Bullet item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for single ordered (number) item. # =pod =over =item 1 Number item =back =cut # # # Expected output. # # \# Number item ############################################################################### # # NAME: Test for ordered (number) list,
                                        . # =pod =over =item 1 Number item 1.0 =item 2 Number item 2.0 =item 3 Number item 3.0 =back =cut # # # Expected output. # # \# Number item 1.0 \# Number item 2.0 \# Number item 3.0 ############################################################################### # # NAME: Test for nested ordered (number) list,
                                          . # =pod =over =item 1 Number item 1.0 =over =item 1 Number item 1.1 =over =item 1 Number item 1.2 =item 2 Number item 2.2 =back =item 2 Number item 2.1 =back =item 2 Number item 2.0 =back =cut # # # Expected output. # # \# Number item 1.0 \## Number item 1.1 \### Number item 1.2 \### Number item 2.2 \## Number item 2.1 \# Number item 2.0 ################################################################################ # # NAME: Test for single definition list item. # =pod =over =item Foo Definition item =back =cut # # # Expected output. # # ; Foo :Definition item ############################################################################### # # NAME: Test for definition list,
                                          . # =pod =over =item Foo Definition item 1.0 =item Bar Definition item 2.0 =item Baz Definition item 3.0 =back =cut # # # Expected output. # # ; Foo :Definition item 1.0 ; Bar :Definition item 2.0 ; Baz :Definition item 3.0 ############################################################################### # # NAME: Test for nested definition list,
                                          . # =pod =over =item Foo Definition item 1.0 =over =item Foo Definition item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item Bar Definition item 2.1 =back =item Bar Definition item 2.0 =back =cut # # # Expected output. # # ; Foo :Definition item 1.0 :; Foo ::Definition item 1.1 ::; Foo :::Definition item 1.2 ::; Bar :::Definition item 2.2 :; Bar ::Definition item 2.1 ; Bar :Definition item 2.0 ############################################################################### # # NAME: Test for varied nested list (incorrect). # # Note that the output is not formatted correctly (see the next TODO test) # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 \## Number item 1.1 ::; Foo :::Definition item 1.2 ::; Bar :::Definition item 2.2 \## Number item 2.1 * Bullet item 2.0 ############################################################################### # # NAME: Test for varied nested list. # # TODO: Nest lists correctly # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 *# Number item 1.1 *#; Foo *#:Definition item 1.2 *#; Bar *#:Definition item 2.2 *# Number item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for definition list without =items,
                                          . # =pod =over This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # :This is a long sentence that forms part of a definition block. ################################################################################ # # NAME: Test for definition list without a definition. # =pod =over =item This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # ; This is a long sentence that forms part of a definition block. ################################################################################ # # NAME: Test 2 for definition list without a definition. # # TODO: Needs a newline after the first item # =pod =over =item This is a long sentence that forms part of a definition block. =item This is the next item. =back =cut # # # Expected output. # # ; This is a long sentence that forms part of a definition block. ; This is the next item. ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/t/05_04_mediawiki_links.t000644 000765 000024 00000003462 12036566301 020763 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for L<> links. # # reverse('©'), December 2005, John McNamara, jmcnamara@cpan.org # and Christopher J. Madsen # use strict; use Pod::Simple::Wiki; use Test::More tests => 4; my $style = 'mediawiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Links [ "=pod\n\nL." => qq(http://www.perl.org.\n\n), 'http'], [ qq(=pod\n\nL) => qq([[#METHODS|"METHODS"]]\n\n), 'Internal link'], [ qq(=pod\n\nL) => qq([[Other::Module]]\n\n), 'Other::Module'], [ qq(=pod\n\nL) => qq([[Other::Module#METHODS|"METHODS" in Other::Module]]\n\n), 'Other::Module/METHODS'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head1 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/05_05_mediawiki_custom_tags.t000644 000765 000024 00000003257 12036567257 022211 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for custom formatting codes. # # reverse('©'), October 2012, Peter Hallam, pragmatic@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 1; my $style = 'mediawiki'; my $opts = { custom_tags => { '
                                          '     => "\n",
                                                  '
                                          ' => "\n\n\n", } }; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\n Foo" => qq(\n Foo\n\n\n), 'Syntaxhighlight code' ], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/05_06_mediawiki_transformer_lists.t000644 000765 000024 00000005740 12036567257 023441 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =over ... =back regions. # # reverse('©'), October 2012, Peter Hallam, pragmatic@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 1; my $style = 'mediawiki'; my $opts = { transformer_lists => 1 }; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests; # # Extract tests embedded in _DATA_ section. # my $test_no = 1; my $pod; my $test = ''; my $todo = '';; my $name; while () { if (/^#/) { $name = $1 if /NAME: (.*)/; $todo = $1 if /TODO: (.*)/; if ($test) { if ($test_no % 2) { $pod = $test; } else { push @tests, [$pod, $test, $name, $todo]; $name = ''; $todo = ''; } $test = ''; $test_no++; } next; } s/\r//; # Remove any \r chars that slip in. s/\\t/\t/g; # Sub back in any escaped tabs. s/\\#/#/g; # Sub back in any escaped comments. $test .= $_; } ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, " \t" . $name); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; print "Test ", $test++, ":\t", $name, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __DATA__ ################################################################################ # # Test data. # ################################################################################ # # NAME: Test for varied nested list (incorrect). # # Note that the output is not formatted correctly (see the next TODO test) # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 \## Number item 1.1::; Foo

                                          Definition item 1.2::; Bar

                                          Definition item 2.2## Number item 2.1 * Bullet item 2.0 ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/t/05_07_mediawiki_link_prefix.t000644 000765 000024 00000003377 12036567257 022200 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for the CPANification of L<> links. # # reverse('©'), October 2012, Peter Hallam, pragmatic@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 2; my $style = 'mediawiki'; my $opts = { link_prefix => 'http://search.cpan.org/perldoc?' }; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Links [ qq(=pod\n\nL) => qq([http://search.cpan.org/perldoc?Other::Module Other::Module]\n\n), 'Other::Module'], [ qq(=pod\n\nL) => qq([http://search.cpan.org/perldoc?Other::Module#METHODS "METHODS" in Other::Module]\n\n), 'Other::Module/METHODS'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head1 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/05_08_mediawiki_sentence_case_headers.t000644 000765 000024 00000003573 12036567257 024157 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =head1 pod sentence-cased directives. # # reverse('©'), October 2012, Peter Hallam, pragmatic@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 2; my $style = 'mediawiki'; my $opts = { sentence_case_headers => 1 }; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( [ "=pod\n\n=head1 DESCRIPTION" => qq(==Description==\n)], [ "=pod\n\n=head1 COPYRIGHT & LICENSE" => qq(==Copyright & license==\n)], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: " . encode_escapes($pod)); } ############################################################################### # # Encode escapes to make them visible in the test output. # sub encode_escapes { my $data = $_[0]; for ($data) { s/\t/\\t/g; s/\n/\\n/g; } return $data; } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $pod2 = encode_escapes($pod); $pod2 =~ s/^=pod\\n\\n//; print "Test ", $test++, ":\t", $pod2, "\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __END__ Pod-Simple-Wiki-0.15/t/05_09_mediawiki_remove_name_section.t000644 000765 000024 00000003375 12036567257 023707 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for the removal of a NAME section. # # reverse('©'), October 2012, Peter Hallam, pragmatic@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 1; my $style = 'mediawiki'; my $opts = { remove_name_section => 1 }; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Links [ qq(=pod\n\n=head1 NAME\n\nOther::Module - Other abstract\n\n=head1 DESCRIPTION\n\nSome description) => qq(Other abstract\n\n==DESCRIPTION==\nSome description\n\n), 'Other::Module'], # [ qq(=pod\n\n=head1 Name\n\nOther::Module - Other abstract) => qq(Other abstract\n\n), 'Other::Module'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style, $opts); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head1 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); print $pod; } } __END__ Pod-Simple-Wiki-0.15/t/06_01_moinmoin_format.t000644 000765 000024 00000003635 12036566301 021015 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for I<>, B<>, C<> etc., formatting codes. # # reverse('©'), December 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 6; my $style = 'moinmoin'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\nI" => qq(''Foo''\n\n), 'Italic' ], [ "=pod\n\nB" => qq('''Foo'''\n\n), 'Bold' ], [ "=pod\n\nC" => qq(`Foo`\n\n), 'Monospace' ], [ "=pod\n\nF" => qq(''Foo''\n\n), 'Filename' ], # Nested formatting tests [ "=pod\n\nB>" => qq('''''Foo'''''\n\n), 'Bold Italic'], [ "=pod\n\nI>" => qq('''''Foo'''''\n\n), 'Italic Bold'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/06_03_moinmoin_lists.t000644 000765 000024 00000017627 12036566301 020673 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =over ... =back regions. # # reverse('©'), December 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 15; my $style = 'moinmoin'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests; # # Extract tests embedded in _DATA_ section. # my $test_no = 1; my $pod; my $test = ''; my $todo = '';; my $name; while () { if (/^#/) { $name = $1 if /NAME: (.*)/; $todo = $1 if /TODO: (.*)/; if ($test) { if ($test_no % 2) { $pod = $test; } else { push @tests, [$pod, $test, $name, $todo]; $name = ''; $todo = ''; } $test = ''; $test_no++; } next; } s/\r//; # Remove any \r chars that slip in. s/\\t/\t/g; # Sub back in any escaped tabs. s/\\s/ /g; # Sub back in any escaped spaces. s/\\#/#/g; # Sub back in any escaped comments. $test .= $_; } ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, " \t" . $name); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n----\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; print "=== Test ", $test++, ":\t", $name, " ===\n\n"; $parser->parse_string_document($pod); print "\n----\n\n"; } } __DATA__ ################################################################################ # # Test data. # ################################################################################ # # NAME: Test for single unordered (bullet) item. # =pod =over =item * Bullet item =back =cut # # # Expected output. # # * Bullet item ################################################################################ # # NAME: Test for unordered (bullet) list,

                                            . # =pod =over =item * Bullet item 1.0 =item * Bullet item 2.0 =item * Bullet item 3.0 =back =cut # # # Expected output. # # * Bullet item 1.0 * Bullet item 2.0 * Bullet item 3.0 ############################################################################### # # NAME: Test for nested unordered (bullet) list,
                                              . # =pod =over =item * Bullet item 1.0 =over =item * Bullet item 1.1 =over =item * Bullet item 1.2 =item * Bullet item 2.2 =back =item * Bullet item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 * Bullet item 1.1 * Bullet item 1.2 * Bullet item 2.2 * Bullet item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for single ordered (number) item. # =pod =over =item 1 Number item =back =cut # # # Expected output. # # 1. Number item ############################################################################### # # NAME: Test for ordered (number) list,
                                                . # =pod =over =item 1 Number item 1.0 =item 2 Number item 2.0 =item 3 Number item 3.0 =back =cut # # # Expected output. # # 1. Number item 1.0 1. Number item 2.0 1. Number item 3.0 ############################################################################### # # NAME: Test for nested ordered (number) list,
                                                  . # =pod =over =item 1 Number item 1.0 =over =item 1 Number item 1.1 =over =item 1 Number item 1.2 =item 2 Number item 2.2 =back =item 2 Number item 2.1 =back =item 2 Number item 2.0 =back =cut # # # Expected output. # # 1. Number item 1.0 1. Number item 1.1 1. Number item 1.2 1. Number item 2.2 1. Number item 2.1 1. Number item 2.0 ################################################################################ # # NAME: Test for single definition list item. # =pod =over =item Foo Definition item =back =cut # # # Expected output. # # Foo:: Definition item ############################################################################### # # NAME: Test for definition list,
                                                  . # =pod =over =item Foo Definition item 1.0 =item Bar Definition item 2.0 =item Baz Definition item 3.0 =back =cut # # # Expected output. # # Foo:: Definition item 1.0 Bar:: Definition item 2.0 Baz:: Definition item 3.0 ############################################################################### # # NAME: Test for nested definition list,
                                                  . # =pod =over =item Foo Definition item 1.0 =over =item Foo Definition item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item Bar Definition item 2.1 =back =item Bar Definition item 2.0 =back =cut # # # Expected output. # # Foo:: Definition item 1.0 Foo:: Definition item 1.1 Foo:: Definition item 1.2 Bar:: Definition item 2.2 Bar:: Definition item 2.1 Bar:: Definition item 2.0 ############################################################################### # # NAME: Test for varied nested list. # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 1. Number item 1.1 Foo:: Definition item 1.2 Bar:: Definition item 2.2 1. Number item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for definition list without =items,
                                                  . # =pod =over This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # This is a long sentence that forms part of a definition block. ################################################################################ # # NAME: Test for definition list without a definition. # # TODO: Fix this later. # =pod =over =item This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # This is a long sentence that forms part of a definition block.::\s ################################################################################ # # NAME: Test for unordered list with included paragraphs. # # TODO: Fix this later. # # =pod =over =item * This is the main item. This is a follow-on paragraph. And this is another. =back =cut # # # Expected output. # # * This is the main item. This is a follow-on paragraph. And this is another. ################################################################################ # # NAME: Test for numbered list with included paragraphs. # # # TODO: Fix this later. # # =pod =over =item 1. This is the main item. This is a follow-on paragraph. And this is another. =back =cut # # # Expected output. # # 1. This is the main item. This is a follow-on paragraph. And this is another. ################################################################################ # # NAME: Test for unordered list with included paragraphs. # # TODO: Fix this later. # # =pod =over =item Term This is the main item. This is a follow-on paragraph. And this is another. =back =cut # # # Expected output. # # Term:: This is the main item. This is a follow-on paragraph. And this is another. ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/t/07_01_tiddlywiki_format.t000644 000765 000024 00000003661 12036566301 021345 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for I<>, B<>, C<> etc., formatting codes. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 6; my $style = 'tiddlywiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\nI" => qq(//Foo//\n\n), 'Italic' ], [ "=pod\n\nB" => qq(''Foo''\n\n), 'Bold' ], [ "=pod\n\nC" => qq({{{Foo}}}\n\n), 'Monospace' ], [ "=pod\n\nF" => qq(//Foo//\n\n), 'Filename' ], # Nested formatting tests [ "=pod\n\nB>" => qq(''//Foo//''\n\n), 'Bold Italic'], [ "=pod\n\nI>" => qq(//''Foo''//\n\n), 'Italic Bold'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/07_02_tiddlywiki_head.t000644 000765 000024 00000003561 12036566301 020756 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =head pod directives. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 4; my $style = 'tiddlywiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( [ "=pod\n\n=head1 Head 1" => qq(!Head 1\n) ], [ "=pod\n\n=head2 Head 2" => qq(!!Head 2\n) ], [ "=pod\n\n=head3 Head 3" => qq(!!!Head 3\n) ], [ "=pod\n\n=head4 Head 4" => qq(!!!!Head 4\n)], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: " . encode_escapes($pod)); } ############################################################################### # # Encode escapes to make them visible in the test output. # sub encode_escapes { my $data = $_[0]; for ($data) { s/\t/\\t/g; s/\n/\\n/g; } return $data; } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $pod2 = encode_escapes($pod); $pod2 =~ s/^=pod\\n\\n//; print "Test ", $test++, ":\t", $pod2, "\n"; $parser->parse_string_document($pod); print "\n"; } } __END__ Pod-Simple-Wiki-0.15/t/07_03_tiddlywiki_lists.t000644 000765 000024 00000015227 12036566301 021216 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =over ... =back regions. # # reverse('©'), March 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 12; my $style = 'tiddlywiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests; # # Extract tests embedded in _DATA_ section. # my $test_no = 1; my $pod; my $test = ''; my $todo = '';; my $name; while () { if (/^#/) { $name = $1 if /NAME: (.*)/; $todo = $1 if /TODO: (.*)/; if ($test) { if ($test_no % 2) { $pod = $test; } else { push @tests, [$pod, $test, $name, $todo]; $name = ''; $todo = ''; } $test = ''; $test_no++; } next; } s/\r//; # Remove any \r chars that slip in. s/\\t/\t/g; # Sub back in any escaped tabs. s/\\#/#/g; # Sub back in any escaped comments. $test .= $_; } ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, " \t" . $name); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; print "!Test ", $test++, ":\t", $name, "\n"; $parser->parse_string_document($pod); print "\n"; } } __DATA__ ################################################################################ # # Test data. # ################################################################################ # # NAME: Test for single unordered (bullet) item. # =pod =over =item * Bullet item =back =cut # # # Expected output. # # * Bullet item ################################################################################ # # NAME: Test for unordered (bullet) list,
                                                    . # =pod =over =item * Bullet item 1.0 =item * Bullet item 2.0 =item * Bullet item 3.0 =back =cut # # # Expected output. # # * Bullet item 1.0 * Bullet item 2.0 * Bullet item 3.0 ############################################################################### # # NAME: Test for nested unordered (bullet) list,
                                                      . # =pod =over =item * Bullet item 1.0 =over =item * Bullet item 1.1 =over =item * Bullet item 1.2 =item * Bullet item 2.2 =back =item * Bullet item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 ** Bullet item 1.1 *** Bullet item 1.2 *** Bullet item 2.2 ** Bullet item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for single ordered (number) item. # =pod =over =item 1 Number item =back =cut # # # Expected output. # # \# Number item ############################################################################### # # NAME: Test for ordered (number) list,
                                                        . # =pod =over =item 1 Number item 1.0 =item 2 Number item 2.0 =item 3 Number item 3.0 =back =cut # # # Expected output. # # \# Number item 1.0 \# Number item 2.0 \# Number item 3.0 ############################################################################### # # NAME: Test for nested ordered (number) list,
                                                          . # =pod =over =item 1 Number item 1.0 =over =item 1 Number item 1.1 =over =item 1 Number item 1.2 =item 2 Number item 2.2 =back =item 2 Number item 2.1 =back =item 2 Number item 2.0 =back =cut # # # Expected output. # # \# Number item 1.0 \#\# Number item 1.1 \#\#\# Number item 1.2 \#\#\# Number item 2.2 \#\# Number item 2.1 \# Number item 2.0 ################################################################################ # # NAME: Test for single definition list item. # =pod =over =item Foo Definition item =back =cut # # # Expected output. # # * Foo Definition item ############################################################################### # # NAME: Test for definition list,
                                                          . # =pod =over =item Foo Definition item 1.0 =item Bar Definition item 2.0 =item Baz Definition item 3.0 =back =cut # # # Expected output. # # * Foo Definition item 1.0 * Bar Definition item 2.0 * Baz Definition item 3.0 ############################################################################### # # NAME: Test for nested definition list,
                                                          . # =pod =over =item Foo Definition item 1.0 =over =item Foo Definition item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item Bar Definition item 2.1 =back =item Bar Definition item 2.0 =back =cut # # # Expected output. # # * Foo Definition item 1.0 ** Foo Definition item 1.1 *** Foo Definition item 1.2 *** Bar Definition item 2.2 ** Bar Definition item 2.1 * Bar Definition item 2.0 ############################################################################### # # NAME: Test for varied nested list. # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 \#\# Number item 1.1 *** Foo Definition item 1.2 *** Bar Definition item 2.2 \#\# Number item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for definition list without =items,
                                                          . # # TODO: Fix this later. # =pod =over This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # <<< This is a long sentence that forms part of a definition block. >>> ################################################################################ # # NAME: Test for definition list without a definition. # # TODO: Fix this later. # =pod =over =item This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # * This is a long sentence that forms part of a definition block. ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/t/07_04_tiddlywiki_text.t000644 000765 000024 00000005622 12036566301 021043 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for I<>, B<>, C<> etc., formatting codes. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 24; my $style = 'tiddlywiki'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\nxxC<-->xx" => qq(xx{{{--}}}xx\n\n), 'Escape C<-->' ], [ "=pod\n\nxx--xx--" => qq(xx{{{--}}}xx{{{--}}}\n\n), 'Escape --' ], [ "=pod\n\nxx---xx---" => qq(xx{{{---}}}xx{{{---}}}\n\n), 'Escape ---' ], (map { [ "=pod\n\nxx$_${_}xx$_$_" => qq(xx{{{$_$_}}}xx{{{$_$_}}}\n\n), "Escape $_$_" ] } qw( - / ' _ ^ > ~ @ ) ), [ "=pod\n\nxxEExxEExxEExx" => qq(xx{{{>>}}}xx{{{<<}}}xx{{{//}}}xx\n\n), 'Escape doubles E E E' ], [ "=pod\n\nxx/E/xx" => qq(xx{{{///}}}xx\n\n), 'Escape /E/' ], # WikiWords RT#60650 [ "=pod\n\nWikiWord" => qq(~WikiWord\n\n), 'Escape WikiWord' ], [ "=pod\n\nWikiWWW" => qq(~WikiWWW\n\n), 'Escape -WikiWWW' ], [ "=pod\n\nxxWikiWord" => qq(xxWikiWord\n\n), 'No Escape xxWikiWord' ], [ "=pod\n\n01WikiWord" => qq(01WikiWord\n\n), 'No Escape 01WikiWord' ], [ "=pod\n\nxx_WikiWord" => qq(xx_~WikiWord\n\n), 'Escape xx_WikiWord' ], [ "=pod\n\nWikiWord2" => qq(~WikiWord2\n\n), 'Escape WikiWord2' ], [ "=pod\n\nWiki2Word" => qq(~Wiki2Word\n\n), 'Escape Wiki2Word' ], [ "=pod\n\nWiki-Word" => qq(~Wiki-Word\n\n), 'Escape Wiki-Word' ], [ "=pod\n\n-WikiWord" => qq(-~WikiWord\n\n), 'Escape -WikiWord' ], [ "=pod\n\n-Wiki-Word" => qq(-~Wiki-Word\n\n), 'Escape -Wiki-Word' ], [ "=pod\n\n-Wiki-Word+Wiki-Word" => qq(-~Wiki-Word+~Wiki-Word\n\n), 'Escape -Wiki-Word+Wiki-Word' ], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/08_01_confluence_format.t000644 000765 000024 00000003632 12036566301 021310 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for I<>, B<>, C<> etc., formatting codes. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 6; my $style = 'confluence'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\nI" => qq(_Foo_\n\n), 'Italic' ], [ "=pod\n\nB" => qq(*Foo*\n\n), 'Bold' ], [ "=pod\n\nC" => qq({{Foo}}\n\n), 'Monospace' ], [ "=pod\n\nF" => qq(_Foo_\n\n), 'Filename' ], # Nested formatting tests [ "=pod\n\nB>" => qq(*_Foo_*\n\n), 'Bold Italic'], [ "=pod\n\nI>" => qq(_*Foo*_\n\n), 'Italic Bold'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/08_02_confluence_head.t000644 000765 000024 00000003573 12036566301 020726 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =head pod directives. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 4; my $style = 'confluence'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( [ "=pod\n\n=head1 Head 1" => qq(h1. Head 1\n\n)], [ "=pod\n\n=head2 Head 2" => qq(h2. Head 2\n\n)], [ "=pod\n\n=head3 Head 3" => qq(h3. Head 3\n\n)], [ "=pod\n\n=head4 Head 4" => qq(h4. Head 4\n\n)], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: " . encode_escapes($pod)); } ############################################################################### # # Encode escapes to make them visible in the test output. # sub encode_escapes { my $data = $_[0]; for ($data) { s/\t/\\t/g; s/\n/\\n/g; } return $data; } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $pod2 = encode_escapes($pod); $pod2 =~ s/^=pod\\n\\n//; print "h2. Test ", $test++, ":\t", $pod2, "\n"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/08_03_confluence_lists.t000644 000765 000024 00000015216 12036566301 021161 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =over ... =back regions. # # reverse('©'), March 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 12; my $style = 'confluence'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests; # # Extract tests embedded in _DATA_ section. # my $test_no = 1; my $pod; my $test = ''; my $todo = '';; my $name; while () { if (/^#/) { $name = $1 if /NAME: (.*)/; $todo = $1 if /TODO: (.*)/; if ($test) { if ($test_no % 2) { $pod = $test; } else { push @tests, [$pod, $test, $name, $todo]; $name = ''; $todo = ''; } $test = ''; $test_no++; } next; } s/\r//; # Remove any \r chars that slip in. s/\\t/\t/g; # Sub back in any escaped tabs. s/\\#/#/g; # Sub back in any escaped comments. $test .= $_; } ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, " \t" . $name); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; print "h2. Test ", $test++, ":\t", $name, "\n"; $parser->parse_string_document($pod); } } __DATA__ ################################################################################ # # Test data. # ################################################################################ # # NAME: Test for single unordered (bullet) item. # =pod =over =item * Bullet item =back =cut # # # Expected output. # # * Bullet item ################################################################################ # # NAME: Test for unordered (bullet) list,
                                                            . # =pod =over =item * Bullet item 1.0 =item * Bullet item 2.0 =item * Bullet item 3.0 =back =cut # # # Expected output. # # * Bullet item 1.0 * Bullet item 2.0 * Bullet item 3.0 ############################################################################### # # NAME: Test for nested unordered (bullet) list,
                                                              . # =pod =over =item * Bullet item 1.0 =over =item * Bullet item 1.1 =over =item * Bullet item 1.2 =item * Bullet item 2.2 =back =item * Bullet item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 ** Bullet item 1.1 *** Bullet item 1.2 *** Bullet item 2.2 ** Bullet item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for single ordered (number) item. # =pod =over =item 1 Number item =back =cut # # # Expected output. # # \# Number item ############################################################################### # # NAME: Test for ordered (number) list,
                                                                . # =pod =over =item 1 Number item 1.0 =item 2 Number item 2.0 =item 3 Number item 3.0 =back =cut # # # Expected output. # # \# Number item 1.0 \# Number item 2.0 \# Number item 3.0 ############################################################################### # # NAME: Test for nested ordered (number) list,
                                                                  . # =pod =over =item 1 Number item 1.0 =over =item 1 Number item 1.1 =over =item 1 Number item 1.2 =item 2 Number item 2.2 =back =item 2 Number item 2.1 =back =item 2 Number item 2.0 =back =cut # # # Expected output. # # \# Number item 1.0 \## Number item 1.1 \### Number item 1.2 \### Number item 2.2 \## Number item 2.1 \# Number item 2.0 ################################################################################ # # NAME: Test for single definition list item. # =pod =over =item Foo Definition item =back =cut # # # Expected output. # # * *Foo* Definition item ############################################################################### # # NAME: Test for definition list,
                                                                  . # =pod =over =item Foo Definition item 1.0 =item Bar Definition item 2.0 =item Baz Definition item 3.0 =back =cut # # # Expected output. # # * *Foo* Definition item 1.0 * *Bar* Definition item 2.0 * *Baz* Definition item 3.0 ############################################################################### # # NAME: Test for nested definition list,
                                                                  . # =pod =over =item Foo Definition item 1.0 =over =item Foo Definition item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item Bar Definition item 2.1 =back =item Bar Definition item 2.0 =back =cut # # # Expected output. # # * *Foo* Definition item 1.0 ** *Foo* Definition item 1.1 *** *Foo* Definition item 1.2 *** *Bar* Definition item 2.2 ** *Bar* Definition item 2.1 * *Bar* Definition item 2.0 ############################################################################### # # NAME: Test for varied nested list. # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 \## Number item 1.1 *** *Foo* Definition item 1.2 *** *Bar* Definition item 2.2 \## Number item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for definition list without =items,
                                                                  . # # =pod =over This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # bq. This is a long sentence that forms part of a definition block. ################################################################################ # # NAME: Test for definition list without a definition. # # TODO: Fix this later. # =pod =over =item This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # * *This is a long sentence that forms part of a definition block.* ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/t/08_04_confluence_links.t000644 000765 000024 00000003354 12036566301 021144 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for L<> link formatting codes. # # reverse('©'), January 2011, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 4; my $style = 'confluence'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple URLs. [ "=pod\n\nL" => qq([www.perl.com]\n\n), 'Simple URL' ], [ "=pod\n\nL" => qq([Perl|www.perl.com]\n\n), 'Simple URL with text' ], [ "=pod\n\nL" => qq([Document]\n\n), 'Simple doc link' ], [ "=pod\n\nL" => qq([Doc Link]\n\n), 'Simple doc link' ], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/09_01_textile_format.t000644 000765 000024 00000003650 11245364123 020645 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for I<>, B<>, C<> etc., formatting codes. # # reverse('©'), December 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 6; my $style = 'textile'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( # Simple formatting tests [ "=pod\n\nI" => qq(_Foo_\n\n), 'Italic' ], [ "=pod\n\nB" => qq(*Foo*\n\n), 'Bold' ], [ "=pod\n\nC" => qq(\@Foo\@\n\n), 'Monospace' ], [ "=pod\n\nF" => qq(_Foo_\n\n), 'Filename' ], # Nested formatting tests [ "=pod\n\nB>" => qq(*_Foo_*\n\n), 'Bold Italic'], [ "=pod\n\nI>" => qq(_*Foo*_\n\n), 'Italic Bold'], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: $name"); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $pod =~ s/=pod\n\n//; $pod = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod"; $parser->parse_string_document($pod); } } __END__ Pod-Simple-Wiki-0.15/t/09_02_textile_head.t000644 000765 000024 00000003617 11245364123 020262 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =head pod directives. # # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 4; my $style = 'textile'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests = ( [ "=pod\n\n=head1 Head 1" => qq(h1. Head 1\n\n)], [ "=pod\n\n=head2 Head 2" => qq(h2. Head 2\n\n)], [ "=pod\n\n=head3 Head 3" => qq(h3. Head 3\n\n)], [ "=pod\n\n=head4 Head 4" => qq(h4. Head 4\n\n)], ); ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); is($wiki, $target, "\tTesting: " . encode_escapes($pod)); } ############################################################################### # # Encode escapes to make them visible in the test output. # sub encode_escapes { my $data = $_[0]; for ($data) { s/\t/\\t/g; s/\n/\\n/g; } return $data; } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; for my $test_ref (@tests) { print "\n"; my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $pod2 = encode_escapes($pod); $pod2 =~ s/^=pod\\n\\n//; print "*Test ", $test++, "*: @", $pod2, "@\n\n"; $parser->parse_string_document($pod); print "\n"; } } __END__ Pod-Simple-Wiki-0.15/t/09_03_textile_lists.t000644 000765 000024 00000015312 11245364123 020513 0ustar00Johnstaff000000 000000 #!/usr/bin/perl -w ############################################################################### # # A test for Pod::Simple::Wiki. # # Tests for =over ... =back regions. # # reverse('©'), March 2005, John McNamara, jmcnamara@cpan.org # use strict; use Pod::Simple::Wiki; use Test::More tests => 12; my $style = 'textile'; # Output the tests for visual testing in the wiki. # END{output_tests()}; my @tests; # # Extract tests embedded in _DATA_ section. # my $test_no = 1; my $pod; my $test = ''; my $todo = '';; my $name; while () { if (/^#/) { $name = $1 if /NAME: (.*)/; $todo = $1 if /TODO: (.*)/; if ($test) { if ($test_no % 2) { $pod = $test; } else { push @tests, [$pod, $test, $name, $todo]; $name = ''; $todo = ''; } $test = ''; $test_no++; } next; } s/\r//; # Remove any \r chars that slip in. s/\\t/\t/g; # Sub back in any escaped tabs. s/\\#/#/g; # Sub back in any escaped comments. $test .= $_; } ############################################################################### # # Run the tests. # for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $target = $test_ref->[1]; my $name = $test_ref->[2]; my $todo = $test_ref->[3]; my $wiki; $parser->output_string(\$wiki); $parser->parse_string_document($pod); local $TODO = $todo; is($wiki, $target, " \t" . $name); } ############################################################################### # # Output the tests for visual testing in the wiki. # sub output_tests { my $test = 1; print "\n\n"; for my $test_ref (@tests) { my $parser = Pod::Simple::Wiki->new($style); my $pod = $test_ref->[0]; my $name = $test_ref->[2]; $name =~ s//>/g; print "h2. Test ", $test++, ":\t", $name, "\n\n"; $parser->parse_string_document($pod); } } __DATA__ ################################################################################ # # Test data. # ################################################################################ # # NAME: Test for single unordered (bullet) item. # =pod =over =item * Bullet item =back =cut # # # Expected output. # # * Bullet item ################################################################################ # # NAME: Test for unordered (bullet) list,
                                                                    . # =pod =over =item * Bullet item 1.0 =item * Bullet item 2.0 =item * Bullet item 3.0 =back =cut # # # Expected output. # # * Bullet item 1.0 * Bullet item 2.0 * Bullet item 3.0 ############################################################################### # # NAME: Test for nested unordered (bullet) list,
                                                                      . # =pod =over =item * Bullet item 1.0 =over =item * Bullet item 1.1 =over =item * Bullet item 1.2 =item * Bullet item 2.2 =back =item * Bullet item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 ** Bullet item 1.1 *** Bullet item 1.2 *** Bullet item 2.2 ** Bullet item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for single ordered (number) item. # =pod =over =item 1 Number item =back =cut # # # Expected output. # # \# Number item ############################################################################### # # NAME: Test for ordered (number) list,
                                                                        . # =pod =over =item 1 Number item 1.0 =item 2 Number item 2.0 =item 3 Number item 3.0 =back =cut # # # Expected output. # # \# Number item 1.0 \# Number item 2.0 \# Number item 3.0 ############################################################################### # # NAME: Test for nested ordered (number) list,
                                                                          . # =pod =over =item 1 Number item 1.0 =over =item 1 Number item 1.1 =over =item 1 Number item 1.2 =item 2 Number item 2.2 =back =item 2 Number item 2.1 =back =item 2 Number item 2.0 =back =cut # # # Expected output. # # \# Number item 1.0 \## Number item 1.1 \### Number item 1.2 \### Number item 2.2 \## Number item 2.1 \# Number item 2.0 ################################################################################ # # NAME: Test for single definition list item. # =pod =over =item Foo Definition item =back =cut # # # Expected output. # # - Foo := Definition item ############################################################################### # # NAME: Test for definition list,
                                                                          . # =pod =over =item Foo Definition item 1.0 =item Bar Definition item 2.0 =item Baz Definition item 3.0 =back =cut # # # Expected output. # # - Foo := Definition item 1.0 - Bar := Definition item 2.0 - Baz := Definition item 3.0 ############################################################################### # # NAME: Test for nested definition list,
                                                                          . # =pod =over =item Foo Definition item 1.0 =over =item Foo Definition item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item Bar Definition item 2.1 =back =item Bar Definition item 2.0 =back =cut # # # Expected output. # # - Foo := Definition item 1.0 - Foo := Definition item 1.1 - Foo := Definition item 1.2 - Bar := Definition item 2.2 - Bar := Definition item 2.1 - Bar := Definition item 2.0 ############################################################################### # # NAME: Test for varied nested list. # =pod =over =item * Bullet item 1.0 =over =item 1 Number item 1.1 =over =item Foo Definition item 1.2 =item Bar Definition item 2.2 =back =item 2 Number item 2.1 =back =item * Bullet item 2.0 =back =cut # # # Expected output. # # * Bullet item 1.0 \## Number item 1.1 - Foo := Definition item 1.2 - Bar := Definition item 2.2 \## Number item 2.1 * Bullet item 2.0 ################################################################################ # # NAME: Test for definition list without =items,
                                                                          . # =pod =over This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # bq.. This is a long sentence that forms part of a definition block. ################################################################################ # # NAME: Test for definition list without a definition. # # TODO: Fix this later. # =pod =over =item This is a long sentence that forms part of a definition block. =back =cut # # # Expected output. # # - := This is a long sentence that forms part of a definition block. ############################################################################### # # End # ############################################################################### Pod-Simple-Wiki-0.15/lib/Pod/000755 000765 000024 00000000000 12036610111 015631 5ustar00Johnstaff000000 000000 Pod-Simple-Wiki-0.15/lib/Pod/Simple/000755 000765 000024 00000000000 12036610111 017062 5ustar00Johnstaff000000 000000 Pod-Simple-Wiki-0.15/lib/Pod/Simple/Wiki/000755 000765 000024 00000000000 12036610111 017765 5ustar00Johnstaff000000 000000 Pod-Simple-Wiki-0.15/lib/Pod/Simple/Wiki.pm000644 000765 000024 00000037537 12036606657 020366 0ustar00Johnstaff000000 000000 package Pod::Simple::Wiki; ############################################################################### # # Pod::Simple::Wiki - A class for creating Pod to Wiki filters. # # # Copyright 2003-2012, John McNamara, jmcnamara@cpan.org # # Documentation after __END__ # # perltidy with the following options: -mbl=2 -pt=0 -nola use strict; #use Pod::Simple::Debug (5); use Pod::Simple; use vars qw(@ISA $VERSION); @ISA = qw(Pod::Simple); $VERSION = '0.15'; ############################################################################### # # The tag to wiki mappings. # my $tags = { '' => "'''", '' => "'''", '' => "''", '' => "''", '' => '"', '' => '"', '
                                                                          '  => '',
                                                                              '
                                                                          ' => "\n\n", '

                                                                          ' => "\n----\n'''", '

                                                                          ' => "'''\n\n", '

                                                                          ' => "\n'''''", '

                                                                          ' => "'''''\n\n", '

                                                                          ' => "\n''", '

                                                                          ' => "''\n\n", '

                                                                          ' => "\n", '

                                                                          ' => "\n\n", }; ############################################################################### # # new() # # Simple constructor inheriting from Pod::Simple. # sub new { my $class = shift; my $format = lc shift || 'wiki'; $format = 'mediawiki' if $format eq 'wikipedia'; $format = 'moinmoin' if $format eq 'moin'; my $module = "Pod::Simple::Wiki::" . ucfirst $format; # Try to load a sub-module unless the format type is 'wiki' in which # case we use this, the parent, module. It's a design pattern, bitches! if ( $format ne 'wiki' ) { eval "require $module"; die "Module $module not implemented for wiki format $format\n" if $@; return $module->new( @_ ); } my $self = Pod::Simple->new( @_ ); $self->{_wiki_text} = ''; $self->{_tags} = $tags; $self->{output_fh} ||= *STDOUT{IO}; $self->{_item_indent} = 0; $self->{_debug} = 0; # Set Pod::Simple parser options # - Merge contiguous text RT#60304 $self->merge_text( 1 ); # - Ignore X<> (index entries) RT#60307 $self->nix_X_codes( 1 ); bless $self, $class; return $self; } ############################################################################### # # _debug() # # Sets the debug flag for some Pod::Simple::Wiki debugging. See also the # Pod::Simple::Debug module. # sub _debug { my $self = shift; $self->{_debug} = $_[0]; } ############################################################################### # # _append() # # Appends some text to the buffered Wiki text. # sub _append { my $self = shift; $self->{_wiki_text} .= $_[0]; } ############################################################################### # # _output() # # Appends some text to the buffered Wiki text and then emits it. Also resets # the buffer. # sub _output { my $self = shift; my $text = $_[0]; $text = '' unless defined $text; print { $self->{output_fh} } $self->{_wiki_text}, $text; $self->{_wiki_text} = ''; } ############################################################################### # # _indent_item() # # Indents an "over-item" to the correct level. # sub _indent_item { my $self = shift; my $item_type = $_[0]; my $item_param = $_[1]; my $indent_level = $self->{_item_indent}; if ( $item_type eq 'bullet' ) { $self->_append( "*" x $indent_level ); # This was the way C2 Wiki used to define a bullet list # $self->_append("\t" x $indent_level . '*'); } elsif ( $item_type eq 'number' ) { $self->_append( "\t" x $indent_level . $item_param ); } elsif ( $item_type eq 'text' ) { $self->_append( "\t" x $indent_level ); } } ############################################################################### # # _skip_headings() # # Formatting in headings doesn't look great or is ignored in some formats. # sub _skip_headings { my $self = shift; return 0; } ############################################################################### # # _append_tag() # # Add an open or close tag to the current text. # sub _append_tag { my $self = shift; my $tag = $_[0]; $self->_append( $self->{_tags}->{$tag} ); } ############################################################################### ############################################################################### # # The methods in the following section are required by Pod::Simple to handle # Pod directives and elements. # # The methods _handle_element_start() _handle_element_end() and _handle_text() # are called by Pod::Simple in response to Pod constructs. We use # _handle_element_start() and _handle_element_end() to generate calls to more # specific methods. This is basically a long-hand version of Pod::Simple:: # Methody with the addition of location tracking. # ############################################################################### # # _handle_element_start() # # Call a method to handle the start of a element if one has been defined. # We also set a flag to indicate that we are "in" the element type. # sub _handle_element_start { my $self = shift; my $element = $_[0]; $element =~ tr/-/_/; if ( $self->{_debug} ) { print ' ' x $self->{_item_indent}, "<$element>\n"; } $self->{ "_in_" . $element }++; if ( my $method = $self->can( '_start_' . $element ) ) { $method->( $self, $_[1] ); } } ############################################################################### # # _handle_element_end() # # Call a method to handle the end of a element if one has been defined. # We also set a flag to indicate that we are "out" of the element type. # sub _handle_element_end { my $self = shift; my $element = $_[0]; $element =~ tr/-/_/; if ( my $method = $self->can( '_end_' . $element ) ) { $method->( $self ); } $self->{ "_in_" . $element }--; if ( $self->{_debug} ) { print "\n", ' ' x $self->{_item_indent}, "\n\n"; } } ############################################################################### # # _handle_text() # # Perform any necessary transforms on the text. This is mainly used to escape # inadvertent CamelCase words. # sub _handle_text { my $self = shift; my $text = $_[0]; # Split the text into tokens but maintain the whitespace my @tokens = split /(\s+)/, $text; for ( @tokens ) { next unless /\S/; # Ignore the whitespace next if m[^(ht|f)tp://]; # Ignore URLs s/([A-Z][a-z]+)(?=[A-Z])/$1''''''/g # Escape with 6 single quotes } # Rejoin the tokens and whitespace. $self->{_wiki_text} .= join '', @tokens; } ############################################################################### # # Functions to deal with the I<>, B<> and C<> formatting codes. # sub _start_I { $_[0]->_append_tag( '' ) unless $_[0]->_skip_headings() } sub _start_B { $_[0]->_append_tag( '' ) unless $_[0]->_skip_headings() } sub _start_C { $_[0]->_append_tag( '' ) unless $_[0]->_skip_headings() } sub _start_F { $_[0]->_start_I } sub _end_I { $_[0]->_append_tag( '' ) unless $_[0]->_skip_headings() } sub _end_B { $_[0]->_append_tag( '' ) unless $_[0]->_skip_headings() } sub _end_C { $_[0]->_append_tag( '' ) unless $_[0]->_skip_headings() } sub _end_F { $_[0]->_end_I } ############################################################################### # # Functions to deal with the Pod =head directives # sub _start_head1 { $_[0]->_append_tag( '

                                                                          ' ) } sub _start_head2 { $_[0]->_append_tag( '

                                                                          ' ) } sub _start_head3 { $_[0]->_append_tag( '

                                                                          ' ) } sub _start_head4 { $_[0]->_append_tag( '

                                                                          ' ) } sub _end_head1 { $_[0]->_append_tag( '

                                                                          ' ); $_[0]->_output() } sub _end_head2 { $_[0]->_append_tag( '' ); $_[0]->_output() } sub _end_head3 { $_[0]->_append_tag( '' ); $_[0]->_output() } sub _end_head4 { $_[0]->_append_tag( '' ); $_[0]->_output() } ############################################################################### # # Functions to deal with verbatim paragraphs. We emit the text "as is" for now. # TODO: escape any Wiki formatting in text such as ''code''. # sub _start_Verbatim { $_[0]->_append_tag( '
                                                                          ' ) }
                                                                          sub _end_Verbatim { $_[0]->_append_tag( '
                                                                          ' ); $_[0]->_output() } ############################################################################### # # Functions to deal with =over ... =back regions for # # Bulleted lists # Numbered lists # Text lists # Block lists # sub _start_over_bullet { $_[0]->{_item_indent}++ } sub _start_over_number { $_[0]->{_item_indent}++ } sub _start_over_text { $_[0]->{_item_indent}++ } sub _end_over_bullet { $_[0]->{_item_indent}--; $_[0]->_output( "\n" ) unless $_[0]->{_item_indent}; } sub _end_over_number { $_[0]->{_item_indent}--; $_[0]->_output( "\n" ) unless $_[0]->{_item_indent}; } sub _end_over_text { $_[0]->{_item_indent}--; $_[0]->_output( "\n" ) unless $_[0]->{_item_indent}; } sub _start_item_bullet { $_[0]->_indent_item( 'bullet' ) } sub _start_item_number { $_[0]->_indent_item( 'number', $_[1]->{number} ) } sub _start_item_text { $_[0]->_indent_item( 'text' ) } sub _end_item_bullet { $_[0]->_output( "\n" ) } sub _end_item_number { $_[0]->_output( "\n" ) } sub _end_item_text { $_[0]->_output( ":\t" ) } # Format specific. sub _start_over_block { $_[0]->{_item_indent}++ } sub _end_over_block { $_[0]->{_item_indent}-- } ############################################################################### # # _start_Para() # # Special handling for paragraphs that are part of an "over" block. # sub _start_Para { my $self = shift; my $indent_level = $self->{_item_indent}; if ( $self->{_in_over_block} ) { $self->_append( ( "\t" x $indent_level ) . " :\t" ); } } ############################################################################### # # _end_Para() # # Special handling for paragraphs that are part of an "over_text" block. # sub _end_Para { my $self = shift; # Only add a newline if the paragraph isn't part of a text if ( $self->{_in_over_text} ) { # Do nothing in this format. } else { $self->_output( "\n" ); } $self->_output( "\n" ); } 1; __END__ =pod =encoding utf8 =head1 NAME Pod::Simple::Wiki - A class for creating Pod to Wiki filters. =head1 VERSION This document refers to version 0.15 of Pod::Simple::Wiki, released October 14 2012. =head1 SYNOPSIS To create a simple filter to convert from Pod to a wiki format: #!/usr/bin/perl use strict; use warnings; use Pod::Simple::Wiki; my $parser = Pod::Simple::Wiki->new('kwiki'); if ( defined $ARGV[0] ) { open IN, $ARGV[0] or die "Couldn't open $ARGV[0]: $!\n"; } else { *IN = *STDIN; } if ( defined $ARGV[1] ) { open OUT, ">$ARGV[1]" or die "Couldn't open $ARGV[1]: $!\n"; } else { *OUT = *STDOUT; } $parser->output_fh( *OUT ); $parser->parse_file( *IN ); __END__ To convert Pod to a wiki format using the installed C utility: pod2wiki --style mediawiki file.pod > file.wiki =head1 DESCRIPTION The C module is used for converting Pod text to Wiki text. Pod (Plain Old Documentation) is a simple markup language used for writing Perl documentation. A Wiki is a user extensible web site. It uses very simple mark-up that is converted to Html. For an introduction to Wikis see: L =head1 METHODS =head2 new('wiki_format') The C method is used to create a new C object. It is also used to set the output Wiki format. my $parser1 = Pod::Simple::Wiki->new( 'wiki' ); my $parser2 = Pod::Simple::Wiki->new( 'mediawiki' ); my $parser3 = Pod::Simple::Wiki->new(); # Defaults to 'wiki' The currently supported formats are: wiki kwiki usemod twiki tiddlywiki textile wikipedia or mediawiki moinmoin confluence =head2 Other methods Pod::Simple::Wiki inherits all of the methods of C. See L for more details. =head1 Supported Formats The following wiki formats are supported by C: =over 4 =item wiki This is the original Wiki format as used on Ward Cunningham's Portland repository of Patterns. See L. =item kwiki This is the format as used by Brian Ingerson's Kwiki: L. =item usemod This is the format used by the Usemod wikis. See: L. =item twiki This is the format used by TWiki wikis. See: L. =item tiddlywiki This is the format used by the TiddlyWiki. See: L. =item textile The Textile markup format as used on GitHub. See: L. =item wikipedia or mediawiki This is the format used by Wikipedia and MediaWiki wikis. See: L. =item moinmoin This is the format used by MoinMoin wikis. See: L. =item confluence This is the format used by Confluence. See: L. =back If no format is specified the parser defaults to C. Any other parameters in C will be passed on to the parent C object. See L for more details. =head1 Porting New Wiki Formats If you are interested in porting a new wiki format have a look at L. The C git repository is: L. =head1 SEE ALSO This module also installs a C command line utility. See C for details. =head1 TODO =over 4 =item * Fix some of the C<=over> edge cases. See the TODOs in the test programs. =back =head1 ACKNOWLEDGEMENTS Thanks to Sean M. Burke for C. It may not be simple but sub-classing it is. C<:-)> Thanks to Sam Tregar for TWiki support. Thanks Tony Sidaway for Wikipedia/MediaWiki support. Thanks to Michael Matthews for MoinMoin support. Thanks to Christopher J. Madsen for several MediaWiki additions and tests. Thanks Tim Bunce for the TiddlyWiki prod and Ron Savage for the port. Thanks to Olivier 'dolmen' MenguE for various TiddlyWiki patches. Thanks to David Bartle, Andrew Hobbs and Jim Renwick for confluence patches. Thanks to Peter Hallam for MediaWiki enhancements. =head1 DISCLAIMER OF WARRANTY Because this software is licensed free of charge, there is no warranty for the software, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the software "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the software is with you. Should the software prove defective, you assume the cost of all necessary servicing, repair, or correction. In no event unless required by applicable law or agreed to in writing will any copyright holder, or any other party who may modify and/or redistribute the software as permitted by the above licence, be liable to you for damages, including any general, special, incidental, or consequential damages arising out of the use or inability to use the software (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the software to operate with any other software), even if such holder or other party has been advised of the possibility of such damages. =head1 LICENSE Either the Perl Artistic Licence L or the GPL L. =head1 AUTHOR John McNamara jmcnamara@cpan.org =head1 COPYRIGHT MMIII-MMVII, John McNamara. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. Pod-Simple-Wiki-0.15/lib/Pod/Simple/Wiki/Confluence.pm000644 000765 000024 00000013702 12036575313 022425 0ustar00Johnstaff000000 000000 package Pod::Simple::Wiki::Confluence; ############################################################################### # # Pod::Simple::Wiki::Confluence - A class for creating Pod to Confluence filters. # # # Copyright 2003-2012, John McNamara, jmcnamara@cpan.org # # Documentation after __END__ # # perltidy with the following options: -mbl=2 -pt=0 -nola use Pod::Simple::Wiki; use strict; use vars qw(@ISA $VERSION); @ISA = qw(Pod::Simple::Wiki); $VERSION = '0.15'; ############################################################################### # # The tag to wiki mappings. # my $tags = { '' => '*', '' => '*', '' => '_', '' => '_', '' => '{{', '' => '}}', '
                                                                          '  => "{noformat}\n",
                                                                              '
                                                                          ' => "\n{noformat}\n", '

                                                                          ' => 'h1. ', '

                                                                          ' => "\n\n", '

                                                                          ' => 'h2. ', '

                                                                          ' => "\n\n", '

                                                                          ' => 'h3. ', '

                                                                          ' => "\n\n", '

                                                                          ' => 'h4. ', '

                                                                          ' => "\n\n", }; ############################################################################### # # new() # # Simple constructor inheriting from Pod::Simple::Wiki. # sub new { my $class = shift; my $self = Pod::Simple::Wiki->new( 'wiki', @_ ); $self->{_tags} = $tags; bless $self, $class; return $self; } ############################################################################### # # _indent_item() # # Indents an "over-item" to the correct level. # sub _indent_item { my $self = shift; my $item_type = $_[0]; my $item_param = $_[1]; my $indent_level = $self->{_item_indent}; if ( $item_type eq 'bullet' ) { $self->_append( '*' x $indent_level . ' ' ); } elsif ( $item_type eq 'number' ) { $self->_append( '#' x $indent_level . ' ' ); } # Confluence doesn't have the equivalent of a
                                                                          list so we use a # bullet list with a bolded "item" as a workaround. elsif ( $item_type eq 'text' ) { $self->_append( '*' x $indent_level . ' *' ); } } ############################################################################### # # _handle_text() # # Perform any necessary transforms on the text. This is mainly used to escape # inadvertent CamelCase words. # sub _handle_text { my $self = shift; my $text = $_[0]; # Only escape words in paragraphs if ( not $self->{_in_Para} ) { $self->{_wiki_text} .= $text; return; } # Split the text into tokens but maintain the whitespace my @tokens = split /(\s+)/, $text; # Escape any tokens here, if necessary. # Rejoin the tokens and whitespace. $self->{_wiki_text} .= join '', @tokens; } ############################################################################### # # Functions to deal with =over ... =back regions for # # Bulleted lists # Numbered lists # Text lists # Block lists # sub _end_item_text { $_[0]->_output( '* ' ) } ############################################################################### # # _start_Para() # # Special handling for paragraphs that are part of an "over" block. # sub _start_Para { my $self = shift; my $indent_level = $self->{_item_indent}; if ( $self->{_in_over_block} ) { $self->_append( 'bq. ' ); } } ############################################################################### # # _start_L() # # Handle the start of a link element. # sub _start_L { my $self = shift; my $link_attrs = shift; $self->{_link_attrs} = $link_attrs; # Ouput start of Confluence link and flush the _wiki_text buffer. $self->_output( '[' ); } ############################################################################### # # _end_L() # # Handle the end of a link element. # sub _end_L { my $self = shift; my $link_attrs = $self->{_link_attrs}; my $link_target = $link_attrs->{to}; my $link_section = $link_attrs->{section}; # Handle links that are parsed as Pod links. if ( defined $link_section ) { $link_target = $link_section; # Remove quotes around link name. $self->{_wiki_text} =~ s/^"//; $self->{_wiki_text} =~ s/"$//; } # Only write [text|link] if text and link are different. if ( $self->{_wiki_text} ne $link_target ) { $self->_append( "|$link_target]" ); } else { $self->_append( "]" ); } } 1; __END__ =head1 NAME Pod::Simple::Wiki::Confluence - A class for creating Pod to Confluence wiki filters. =head1 SYNOPSIS This module isn't used directly. Instead it is called via C: #!/usr/bin/perl -w use strict; use Pod::Simple::Wiki; my $parser = Pod::Simple::Wiki->new('confluence'); ... Convert Pod to a Confluence wiki format using the installed C utility: pod2wiki --style confluence file.pod > file.wiki =head1 DESCRIPTION The C module is used for converting Pod text to Wiki text. Pod (Plain Old Documentation) is a simple markup language used for writing Perl documentation. For an introduction to Confluence see: L This module isn't generally invoked directly. Instead it is called via C. See the L and L documentation for more information. =head1 METHODS Pod::Simple::Wiki::Confluence inherits all of the methods of C and C. See L and L for more details. =head1 SEE ALSO This module also installs a C command line utility. See C for details. =head1 ACKNOWLEDGEMENTS Thanks to David Bartle, Andrew Hobbs and Jim Renwick for patches. =head1 DISCLAIMER OF WARRANTY Please refer to the DISCLAIMER OF WARRANTY in L. =head1 AUTHORS John McNamara jmcnamara@cpan.org =head1 COPYRIGHT MMIII-MMXII, John McNamara. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. Pod-Simple-Wiki-0.15/lib/Pod/Simple/Wiki/Kwiki.pm000644 000765 000024 00000013300 12036575265 021422 0ustar00Johnstaff000000 000000 package Pod::Simple::Wiki::Kwiki; ############################################################################### # # Pod::Simple::Wiki::Kwiki - A class for creating Pod to Kwiki filters. # # # Copyright 2003-2012, John McNamara, jmcnamara@cpan.org # # Documentation after __END__ # # perltidy with the following options: -mbl=2 -pt=0 -nola use Pod::Simple::Wiki; use strict; use vars qw(@ISA $VERSION); @ISA = qw(Pod::Simple::Wiki); $VERSION = '0.15'; ############################################################################### # # The tag to wiki mappings. # my $tags = { '' => '*', '' => '*', '' => '/', '' => '/', '' => '[=', '' => ']', '
                                                                          '  => '',
                                                                              '
                                                                          ' => "\n\n", '

                                                                          ' => "\n----\n= ", '

                                                                          ' => " =\n\n", '

                                                                          ' => "\n== ", '

                                                                          ' => " ==\n\n", '

                                                                          ' => "\n=== ", '

                                                                          ' => " ===\n\n", '

                                                                          ' => "==== ", '

                                                                          ' => "\n\n", }; ############################################################################### # # new() # # Simple constructor inheriting from Pod::Simple::Wiki. # sub new { my $class = shift; my $self = Pod::Simple::Wiki->new( 'wiki', @_ ); $self->{_tags} = $tags; bless $self, $class; return $self; } ############################################################################### # # _indent_item() # # Indents an "over-item" to the correct level. # sub _indent_item { my $self = shift; my $item_type = $_[0]; my $item_param = $_[1]; my $indent_level = $self->{_item_indent}; if ( $item_type eq 'bullet' ) { $self->_append( '*' x $indent_level . ' ' ); } elsif ( $item_type eq 'number' ) { $self->_append( '0' x $indent_level . ' ' ); } elsif ( $item_type eq 'text' ) { $self->_append( ';' x $indent_level . ' ' ); } } ############################################################################### # # _skip_headings() # # Formatting in headings doesn't look great or is ignored in some formats. # sub _skip_headings { my $self = shift; if ( $self->{_in_head1} or $self->{_in_head2} or $self->{_in_head3} or $self->{_in_head4} ) { return 1; } } ############################################################################### # # _handle_text() # # Perform any necessary transforms on the text. This is mainly used to escape # inadvertent CamelCase words. # sub _handle_text { my $self = shift; my $text = $_[0]; # Only escape CamelCase in Kwiki paragraphs if ( not $self->{_in_Para} ) { $self->{_wiki_text} .= $text; return; } # Split the text into tokens but maintain the whitespace my @tokens = split /(\s+)/, $text; for ( @tokens ) { next unless /\S/; # Ignore the whitespace next if m[^(ht|f)tp://]; # Ignore URLs s/([A-Z][a-z]+[A-Z]\w+)/!$1/g; # Escape with ! } # Rejoin the tokens and whitespace. $self->{_wiki_text} .= join '', @tokens; } ############################################################################### # # Functions to deal with =over ... =back regions for # # Bulleted lists # Numbered lists # Text lists # Block lists # sub _end_item_text { $_[0]->_output( ' ; ' ) } ############################################################################### # # _start_Para() # # Special handling for paragraphs that are part of an "over" block. # sub _start_Para { my $self = shift; my $indent_level = $self->{_item_indent}; if ( $self->{_in_over_block} ) { # Do something here is necessary } } ############################################################################### # # _end_Para() # # Special handling for paragraphs that are part of an "over_text" block. # This is mainly required be Kwiki. # sub _end_Para { my $self = shift; # Only add a newline if the paragraph isn't part of a text. if ( $self->{_in_over_text} ) { # Workaround for the fact that Kwiki doesn't have a definition block. #$self->_output("\n"); } else { $self->_output( "\n" ); } $self->_output( "\n" ); } 1; __END__ =head1 NAME Pod::Simple::Wiki::Kwiki - A class for creating Pod to Kwiki wiki filters. =head1 SYNOPSIS This module isn't used directly. Instead it is called via C: #!/usr/bin/perl -w use strict; use Pod::Simple::Wiki; my $parser = Pod::Simple::Wiki->new('kwiki'); ... Convert Pod to a Kwiki wiki format using the installed C utility: pod2wiki --style kwiki file.pod > file.wiki =head1 DESCRIPTION The C module is used for converting Pod text to Wiki text. Pod (Plain Old Documentation) is a simple markup language used for writing Perl documentation. For an introduction to Kwiki see: L This module isn't generally invoked directly. Instead it is called via C. See the L and L documentation for more information. =head1 METHODS Pod::Simple::Wiki::Kwiki inherits all of the methods of C and C. See L and L for more details. =head1 SEE ALSO This module also installs a C command line utility. See C for details. =head1 ACKNOWLEDGEMENTS Submit a bugfix or test and your name will go here. =head1 DISCLAIMER OF WARRANTY Please refer to the DISCLAIMER OF WARRANTY in L. =head1 AUTHORS John McNamara jmcnamara@cpan.org =head1 COPYRIGHT MMIII-MMXII, John McNamara. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. Pod-Simple-Wiki-0.15/lib/Pod/Simple/Wiki/Mediawiki.pm000644 000765 000024 00000031050 12036606646 022247 0ustar00Johnstaff000000 000000 package Pod::Simple::Wiki::Mediawiki; ############################################################################### # # Pod::Simple::Wiki::Mediawiki - A class for creating Pod to MediaWiki filters. # # # Copyright 2003-2012, John McNamara, jmcnamara@cpan.org # # Documentation after __END__ # # perltidy with the following options: -mbl=2 -pt=0 -nola use Pod::Simple::Wiki; use strict; use vars qw(@ISA $VERSION); @ISA = qw(Pod::Simple::Wiki); $VERSION = '0.15'; ############################################################################### # # The tag to wiki mappings. # my $tags = { '' => "'''", '' => "'''", '' => "''", '' => "''", '' => '', '' => '', '
                                                                          '  => "\n",
                                                                              '
                                                                          ' => "\n\n", '

                                                                          ' => '==', '

                                                                          ' => "==\n", '

                                                                          ' => '===', '

                                                                          ' => "===\n", '

                                                                          ' => '====', '

                                                                          ' => "====\n", '

                                                                          ' => '=====', '

                                                                          ' => "=====\n", }; ############################################################################### # # The default module options # my $default_opts = { transformer_lists => 0, link_prefix => 0, sentence_case_headers => 0, remove_name_section => 0, }; ############################################################################### # # new() # # Simple constructor inheriting from Pod::Simple::Wiki. # sub new { my $class = shift; my $opts = {}; if ( ref $_[-1] eq 'HASH' ) { $opts = pop @_; # Merge custom tags with the default tags, if passed. $opts->{tags} = { %$tags, %{ exists $opts->{custom_tags} ? delete $opts->{custom_tags} : {} } }; } else { $opts->{tags} = $tags; } $opts = { %$default_opts, %$opts }; my $self = Pod::Simple::Wiki->new( 'wiki', @_ ); $self->{_tags} = $opts->{tags}; $self->{_transformer_lists} = $opts->{transformer_lists}; $self->{_link_prefix} = $opts->{link_prefix}; $self->{_sentence_case_headers} = $opts->{sentence_case_headers}; $self->{_remove_name_section} = $opts->{remove_name_section}; bless $self, $class; $self->accept_targets( 'mediawiki' ); $self->nbsp_for_S( 1 ); return $self; } ############################################################################### # # _append() # # Appends some text to the buffered Wiki text. # sub _append { my $self = shift; if ( $self->{_indent_text} ) { $self->{_wiki_text} .= $self->{_indent_text}; $self->{_indent_text} = ''; } $self->{_wiki_text} .= $_[0]; } ############################################################################### # # _indent_item() # # Indents an "over-item" to the correct level. # sub _indent_item { my $self = shift; my $item_type = $_[0]; my $item_param = $_[1]; my $indent_level = $self->{_item_indent}; if ( $item_type eq 'bullet' ) { $self->_append( '*' x $indent_level . ' ' ); } elsif ( $item_type eq 'number' ) { $self->_append( '#' x $indent_level . ' ' ); } elsif ( $item_type eq 'text' ) { $self->_append( ':' x ( $indent_level - 1 ) . '; ' ); } } ############################################################################### # # Functions to deal with links. sub _start_L { my ( $self, $attr ) = @_; if ( !$self->_skip_headings ) { $self->_append( '' ); # In case we have _indent_text pending # Flush the text buffer, so it will contain only the link text $self->_output; $self->{_link_attr} = $attr; # Save for later } } sub _end_L { my $self = $_[0]; my $attr = delete $self->{_link_attr}; if ( $attr and my $method = $self->can( '_format_link' ) ) { $self->{_wiki_text} = $method->( $self, $self->{_wiki_text}, $attr ); } } ############################################################################### # # _format_link sub _format_link { my ( $self, $text, $attr ) = @_; if ( $attr->{type} eq 'url' ) { my $link = $attr->{to}; return $link if $attr->{'content-implicit'}; return "[$link $text]"; } # Manpage: if ( $attr->{type} eq 'man' ) { # FIXME link to http://www.linuxmanpages.com? return "$text" if $attr->{'content-implicit'}; return "$text ($attr->{to})"; } die "Unknown link type $attr->{type}" unless $attr->{type} eq 'pod'; # Handle a link within this page: return "[[#$attr->{section}|$text]]" unless defined $attr->{to}; # Handle a link to a specific section in another page: if ( defined $attr->{section} ) { return $self->{_link_prefix} ? "[$self->{_link_prefix}$attr->{to}#$attr->{section} $text]" : "[[$attr->{to}#$attr->{section}|$text]]"; } if ( $attr->{'content-implicit'} ) { return $self->{_link_prefix} ? "[$self->{_link_prefix}$attr->{to} $attr->{to}]" : "[[$attr->{to}]]"; } return "[[$attr->{to}|$text]]"; } ############################################################################### # # _handle_text() # # Perform any necessary transforms on the text. This is mainly used to escape # inadvertent CamelCase words. # sub _handle_text { my $self = shift; my $text = $_[0]; if ( $self->{_sentence_case_headers} ) { if ( $self->{_in_head1} ) { $text = ucfirst( lc( $text ) ); } } if ( !$self->{_in_Data} ) { # Escape colons in definition lists: if ( $self->{_in_item_text} ) { $text =~ s/:/:/g; # A colon would end the item } # Escape empty lines in verbatim sections: if ( $self->{_in_Verbatim} ) { $text =~ s/^$/ /mg; # An empty line would split the section } $text =~ s/\xA0/ /g; # Convert non-breaking spaces to entities $text =~ s/''/''/g; # It's not a formatting code $text =~ s/\xA9/©/g; # Convert copyright symbols to entities } $self->_append( $text ); } ############################################################################### # # Functions to deal with =over ... =back regions for # # Bulleted lists # Numbered lists # Text lists # Block lists # sub _end_item_text { } # _start_Para will insert the : ############################################################################### # # _start_Para() # # Special handling for paragraphs that are part of an "over" block. # sub _start_Para { my $self = shift; my $indent_level = $self->{_item_indent}; if ( $self->{_in_over_block} ) { $self->{_indent_text} = ( ':' x $indent_level ); } if ( $self->{_in_over_text} ) { $self->{_indent_text} = "\n" . ( ':' x $indent_level ); } if ( $self->{_transformer_lists} ) { if ( $self->{_in_over_bullet} || $self->{_in_over_number} ) { if ( $self->{output_string} ) { chomp( ${ $self->{output_string} } ); } $self->{_indent_text} = "

                                                                          "; } } } ############################################################################### # # _end_Para() # # Special handling for paragraphs that are part of an "over_text" block. # sub _end_Para { my $self = shift; # Only add a newline if the paragraph isn't part of a text if ( $self->{_in_over_text} ) { # Do nothing in this format. } elsif ( $self->{_transformer_lists} && ( $self->{_in_over_bullet} || $self->{_in_over_number} ) ) { $self->_output( "

                                                                          \n" ); } else { $self->_output( "\n" ); } if ( !$self->{_transformer_lists} || ( !$self->{_in_over_bullet} && !$self->{_in_over_number} ) ) { $self->_output( "\n" ); } } ###################################################################### # # _end_Data # # Special handling for data paragraphs sub _end_Data { $_[0]->_output( "\n\n" ) } ############################################################################### # # parse_string_document() # # Optional overriding of Pod::Simple method to remove the "NAME" section # sub parse_string_document { my $self = shift; $self = $self->SUPER::parse_string_document( @_ ); if ( $self->{_remove_name_section} ) { no warnings 'uninitialized'; ${ $self->{output_string} } =~ s/^==\s*NAME\s*==\n(?:[\w:]+)(?: - (.*))*/$1||''/iesg; } return $self; } 1; __END__ =pod =encoding utf8 =head1 NAME Pod::Simple::Wiki::Mediawiki - A class for creating Pod to Mediawiki wiki filters. =head1 SYNOPSIS This module isn't used directly. Instead it is called via C: #!/usr/bin/perl -w use strict; use Pod::Simple::Wiki; my $parser = Pod::Simple::Wiki->new('mediawiki', \%opts); ... Convert Pod to a Mediawiki wiki format using the installed C utility: pod2wiki --style mediawiki file.pod > file.wiki =head1 DESCRIPTION The C module is used for converting Pod text to Wiki text. Pod (Plain Old Documentation) is a simple markup language used for writing Perl documentation. For an introduction to Mediawiki see: http://www.mediawiki.org/wiki/MediaWiki This module isn't generally invoked directly. Instead it is called via C. See the L and L documentation for more information. =head1 METHODS Pod::Simple::Wiki::Mediawiki inherits all of the methods of C and C. See L and L for more details. =head2 new The following options are supported by the C constructor: =over 4 =item B This option accepts a hashref containing the HTML tag to MediaWiki mappings. For example, if your MediaWiki installation has the L extension installed, you could pass the following custom tags to enable your verbatim paragraphs to be syntax highlighted: { custom_tags => { '
                                                                          '     => "\n",
                                                                                      '
                                                                          ' => "\n
                                                                          \n", } } Any custom tags you define will override the classes' default tags as defined in the C<$tags> variable. Defaults to "{}". =item B If enabled, modify the item list output to better support the L style of lists (as used by many L based distros via L). For example, the output of the following list definition: =for :list * Point one This is pointy * Point two That hurts will be transformed into: * Point one

                                                                          This is pointy

                                                                          * Point two

                                                                          That hurts

                                                                          This will be rendered as a bulleted with list headings that have correctly indented paragraph blocks immediately beneath. Defaults to 0. =item B If set, all links without any extra qualifier text are prefixed with the given URL. A useful URL to set this option to is: C, which will enable the links to be correctly resolved to the external links when used within your internal MediaWiki site. Defaults to 0. =item B This option will modify any C<=head1> header by lower-casing it and then upper-casing the first character. For example, this header: =head1 DESCRIPTION becomes: =head1 Description This option is inspired from L in the Wikipedia "Manual of Style". Defaults to 0. =item B If enabled, modify the resultant wiki output text to remove the "NAME" (or "Name") section, but first parse out the embedded abstract text and place that at the top of the wiki page, as a brief introduction. Defaults to 0. =back =head1 SEE ALSO This module also installs a C command line utility. See C for details. =head1 ACKNOWLEDGEMENTS Thanks Tony Sidaway for initial Wikipedia/MediaWiki support. Christopher J. Madsen for several major additions and tests. Peter Hallam added several MediaWiki enhancements. =head1 DISCLAIMER OF WARRANTY Please refer to the DISCLAIMER OF WARRANTY in L. =head1 AUTHORS John McNamara jmcnamara@cpan.org Christopher J. Madsen perl@cjmweb.net =head1 COPYRIGHT MMIII-MMXII, John McNamara. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. Pod-Simple-Wiki-0.15/lib/Pod/Simple/Wiki/Moinmoin.pm000644 000765 000024 00000012114 12036575402 022124 0ustar00Johnstaff000000 000000 package Pod::Simple::Wiki::Moinmoin; ############################################################################### # # Pod::Simple::Wiki::Moinmoin - A class for creating Pod to Moinmoin filters. # # # Copyright 2003-2012, John McNamara, jmcnamara@cpan.org # # Documentation after __END__ # # perltidy with the following options: -mbl=2 -pt=0 -nola use Pod::Simple::Wiki; use strict; use vars qw(@ISA $VERSION); @ISA = qw(Pod::Simple::Wiki); $VERSION = '0.15'; ############################################################################### # # The tag to wiki mappings. # my $tags = { '' => "'''", '' => "'''", '' => "''", '' => "''", '' => '`', '' => '`', '
                                                                          '  => "\n{{{\n",
                                                                              '
                                                                          ' => "\n}}}\n", '

                                                                          ' => "\n== ", '

                                                                          ' => " ==\n\n", '

                                                                          ' => "\n=== ", '

                                                                          ' => " ===\n\n", '

                                                                          ' => "\n==== ", '

                                                                          ' => " ====\n\n", '

                                                                          ' => "\n===== ", '

                                                                          ' => " =====\n\n", }; ############################################################################### # # new() # # Simple constructor inheriting from Pod::Simple::Wiki. # sub new { my $class = shift; my $self = Pod::Simple::Wiki->new( 'wiki', @_ ); $self->{_tags} = $tags; bless $self, $class; return $self; } ############################################################################### # # _indent_item() # # Indents an "over-item" to the correct level. # sub _indent_item { my $self = shift; my $item_type = $_[0]; my $item_param = $_[1]; my $indent_level = $self->{_item_indent}; if ( $item_type eq 'bullet' ) { $self->_append( ' ' x $indent_level . "* " ); } elsif ( $item_type eq 'number' ) { $self->_append( ' ' x $indent_level . "1. " ); } elsif ( $item_type eq 'text' ) { $self->_append( ' ' x $indent_level ); } $self->{_moinmoin_list} = 1; } ############################################################################### # # _handle_text() # # Perform any necessary transforms on the text. This is mainly used to escape # inadvertent CamelCase words. # sub _handle_text { my $self = shift; my $text = $_[0]; # Split the text into tokens but maintain the whitespace my @tokens = split /(\s+)/, $text; # Escape any tokens here. # Rejoin the tokens and whitespace. $self->{_wiki_text} .= join '', @tokens; } ############################################################################### # # Functions to deal with =over ... =back regions for # # Bulleted lists # Numbered lists # Text lists # Block lists # sub _end_item_text { $_[0]->_output( ":: " ); $_[0]->{_moinmoin_list} = 0; } ############################################################################### # # _start_Para() # # Special handling for paragraphs that are part of an "over" block. # sub _start_Para { my $self = shift; my $indent_level = $self->{_item_indent}; if ( $self->{_in_over_block} ) { $self->_append( ' ' x $indent_level ); } if ( $self->{_moinmoin_list} ) { if ( not $self->{_in_over_text} and $self->{_moinmoin_list} == 1 ) { $self->_append( "\n" ); } if ( $self->{_in_over_text} and $self->{_moinmoin_list} == 2 ) { $self->_append( "\n" ); } if ( not( $self->{_in_over_text} and $self->{_moinmoin_list} == 1 ) ) { $self->_append( ' ' x $indent_level ); } $self->{_moinmoin_list}++; } } 1; __END__ =head1 NAME Pod::Simple::Wiki::Moinmoin - A class for creating Pod to Moinmoin wiki filters. =head1 SYNOPSIS This module isn't used directly. Instead it is called via C: #!/usr/bin/perl -w use strict; use Pod::Simple::Wiki; my $parser = Pod::Simple::Wiki->new('moinmoin'); ... Convert Pod to a Moinmoin wiki format using the installed C utility: pod2wiki --style moinmoin file.pod > file.wiki =head1 DESCRIPTION The C module is used for converting Pod text to Wiki text. Pod (Plain Old Documentation) is a simple markup language used for writing Perl documentation. For an introduction to Moinmoin see: L This module isn't generally invoked directly. Instead it is called via C. See the L and L documentation for more information. =head1 METHODS Pod::Simple::Wiki::Moinmoin inherits all of the methods of C and C. See L and L for more details. =head1 SEE ALSO This module also installs a C command line utility. See C for details. =head1 ACKNOWLEDGEMENTS Thanks to Michael Matthews for MoinMoin support. =head1 DISCLAIMER OF WARRANTY Please refer to the DISCLAIMER OF WARRANTY in L. =head1 AUTHORS John McNamara jmcnamara@cpan.org =head1 COPYRIGHT MMIII-MMXII, John McNamara. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. Pod-Simple-Wiki-0.15/lib/Pod/Simple/Wiki/Template.pm000644 000765 000024 00000020500 12036576417 022117 0ustar00Johnstaff000000 000000 package Pod::Simple::Wiki::Template; # Portme: This module is used as a boiler plate or example of how to create a # new C module. # # Read the Portme section of the documentation below for more information. # # Portme. Try to maintain the same code style as this module: # perltidy with the following options: -mbl=2 -pt=0 -nola ############################################################################### # # Pod::Simple::Wiki::Template - A class for creating Pod to Template filters. # # # Copyright 2003-2012, John McNamara, jmcnamara@cpan.org # # Documentation after __END__ # # perltidy with the following options: -mbl=2 -pt=0 -nola use Pod::Simple::Wiki; use strict; use vars qw(@ISA $VERSION); @ISA = qw(Pod::Simple::Wiki); $VERSION = '0.15'; # Portme. Start with these tags. ############################################################################### # # The tag to wiki mappings. # my $tags = { '' => '*', '' => '*', '' => '/', '' => '/', '' => '[=', '' => ']', '
                                                                          '  => '',
                                                                              '
                                                                          ' => "\n\n", '

                                                                          ' => "\n----\n= ", '

                                                                          ' => " =\n\n", '

                                                                          ' => "\n== ", '

                                                                          ' => " ==\n\n", '

                                                                          ' => "\n=== ", '

                                                                          ' => " ===\n\n", '

                                                                          ' => "==== ", '

                                                                          ' => "\n\n", }; # Portme. You can leave new() as it is. ############################################################################### # # new() # # Simple constructor inheriting from Pod::Simple::Wiki. # sub new { my $class = shift; my $self = Pod::Simple::Wiki->new( 'wiki', @_ ); $self->{_tags} = $tags; bless $self, $class; return $self; } # Portme. How Pod "=over" blocks are converted to Template wiki lists. ############################################################################### # # _indent_item() # # Indents an "over-item" to the correct level. # sub _indent_item { my $self = shift; my $item_type = $_[0]; my $item_param = $_[1]; my $indent_level = $self->{_item_indent}; if ( $item_type eq 'bullet' ) { $self->_append( '*' x $indent_level . ' ' ); } elsif ( $item_type eq 'number' ) { $self->_append( '0' x $indent_level . ' ' ); } elsif ( $item_type eq 'text' ) { $self->_append( ';' x $indent_level . ' ' ); } } # Portme: Use this is text tokens need to be escaped, such as CamelCase words. ############################################################################### # # _handle_text() # # Perform any necessary transforms on the text. This is mainly used to escape # inadvertent CamelCase words. # sub _handle_text { my $self = shift; my $text = $_[0]; # Only escape words in paragraphs if ( not $self->{_in_Para} ) { $self->{_wiki_text} .= $text; return; } # Split the text into tokens but maintain the whitespace my @tokens = split /(\s+)/, $text; # Portme: # Escape any tokens here, if necessary. # Rejoin the tokens and whitespace. $self->{_wiki_text} .= join '', @tokens; } # Portme. How Pod "=over" blocks are converted to Template wiki lists. ############################################################################### # # Functions to deal with =over ... =back regions for # # Bulleted lists # Numbered lists # Text lists # Block lists # sub _end_item_text { $_[0]->_output( ' ; ' ) } # Portme: Probably won't have to change this. ############################################################################### # # _start_Para() # # Special handling for paragraphs that are part of an "over" block. # sub _start_Para { my $self = shift; my $indent_level = $self->{_item_indent}; if ( $self->{_in_over_block} ) { # Do something here is necessary } } 1; __END__ =head1 NAME Pod::Simple::Wiki::Template - A class for creating Pod to Template wiki filters. =head1 SYNOPSIS This module isn't used directly. Instead it is called via C: #!/usr/bin/perl -w use strict; use Pod::Simple::Wiki; my $parser = Pod::Simple::Wiki->new('template'); ... Convert Pod to a Template wiki format using the installed C utility: pod2wiki --style template file.pod > file.wiki =head1 DESCRIPTION This module is used as a boiler plate or example of how to create a new C module. See the Portme section below. The C module is used for converting Pod text to Wiki text. Pod (Plain Old Documentation) is a simple markup language used for writing Perl documentation. For an introduction to Template see: L. This module isn't generally invoked directly. Instead it is called via C. See the L and L documentation for more information. =head1 PORTME This module is used as a boiler plate or example of how to create a new C module. If you are thinking of creating a new C you should use this module as a basis. B. Any comments in the code or documentation that begin with or contain the word C are intended for the C, the person who is creating the new module. You should read all of the C comments and eventully delete them when the module is finished. The following are some suggested steps in porting the module. For the sake of example say we wish to convert Pod to a format called C. Also for the sake of this example we will assume that you know how to install and work on a module or work on it in a local source tree using C<-I./lib> or C<-Mblib>. =head2 Portme Step 1 Fork, clone or download the latest version of C from the github repository: L Copy the C to a new module C. The module name should have the first letter capitalised and all others lowercase, i.e, the same as returned by C. =head2 Portme Step 2 Edit the module and replace all instances of C