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: # 4 space indents. # No tabs. # No trailing whitespace. # 79 column wrap. # Consistency. # ############################################################################### # # Pod::Simple::Wiki::Template - A class for creating Pod to Template filters. # # # Copyright 2003-2008, John McNamara, jmcnamara@cpan.org # # Documentation after __END__ # use Pod::Simple::Wiki; use strict; use vars qw(@ISA $VERSION); @ISA = qw(Pod::Simple::Wiki); $VERSION = '0.08'; # 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: http://www.portme.org 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: http://github.com/jmcnamara/pod-simple-wiki/ 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