Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.16 #7

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions Changes
@@ -1,5 +1,15 @@
Revision history for Pod::Simple::Wiki.

0.16 Jan 26 2014
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll handle changes like version numbers and release notes prior to release.


+ Added Dokuwiki support contributed by Joe Cooper
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these changes will need to be a separate Issue/Pull Request.

+ Added rudimentary link support for twiki
+ Added Support for =for and =begin targets for twiki and the Template

! Fix for missing line breaks in lists for twiki
! Fix for RT#71119 Confluence asterisk enumeration
! Fix for RT#38833 Escaping of Confluence special characters

0.15 Oct 14 2012

+ Added options for beautifying MediaWiki output.
Expand Down
6 changes: 6 additions & 0 deletions MANIFEST
Expand Up @@ -13,6 +13,7 @@ lib/Pod/Simple/Wiki/Twiki.pm
lib/Pod/Simple/Wiki/Usemod.pm
lib/Pod/Simple/Wiki/Confluence.pm
lib/Pod/Simple/Wiki/Textile.pm
lib/Pod/Simple/Wiki/Dokuwiki.pm

bin/pod2wiki

Expand All @@ -36,6 +37,11 @@ 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/04_04_twiki_links.t

t/09_01_dokuwiki_format.t
t/09_02_dokuwiki_head.t
t/09_03_dokuwiki_lists.t

t/05_01_mediawiki_format.t
t/05_02_mediawiki_head.t
Expand Down
9 changes: 3 additions & 6 deletions lib/Pod/Simple/Wiki/Confluence.pm
Expand Up @@ -18,7 +18,7 @@ use vars qw(@ISA $VERSION);


@ISA = qw(Pod::Simple::Wiki);
$VERSION = '0.15';
$VERSION = '0.16';

###############################################################################
#
Expand Down Expand Up @@ -99,16 +99,13 @@ sub _handle_text {
my $self = shift;
my $text = $_[0];

# Only escape words in paragraphs
if ( not $self->{_in_Para} ) {
$self->{_wiki_text} .= $text;
return;
}
$text =~ s/\*/\\*/g;

# Split the text into tokens but maintain the whitespace
my @tokens = split /(\s+)/, $text;

# Escape any tokens here, if necessary.
@tokens = map { s/([\[\{-])/\\$1/g; $_ } @tokens;

# Rejoin the tokens and whitespace.
$self->{_wiki_text} .= join '', @tokens;
Expand Down
216 changes: 216 additions & 0 deletions lib/Pod/Simple/Wiki/Dokuwiki.pm
@@ -0,0 +1,216 @@
package Pod::Simple::Wiki::Dokuwiki;

###############################################################################
#
# Pod::Simple::Wiki::Dokuwiki - A class for creating Pod to Dokuwiki filters.
#
#
# Copyright 2003-2008, John McNamara, jmcnamara@cpan.org
# Copyright 2008 Joe Cooper, joe@virtualmin.com
#
# Documentation after __END__
#

use Pod::Simple::Wiki;
use strict;
use vars qw(@ISA $VERSION);


@ISA = qw(Pod::Simple::Wiki);
$VERSION = '0.08';

###############################################################################
#
# The tag to wiki mappings.
#
my $tags = {
'<b>' => '**',
'</b>' => '**',
'<i>' => '//',
'</i>' => '//',
'<tt>' => "''",
'</tt>' => "''",
'<pre>' => "<code>\n",
'</pre>' => "\n</code>",

'<h1>' => "====== ",
'</h1>' => " ======\n",
'<h2>' => "===== ",
'</h2>' => " =====\n",
'<h3>' => "==== ",
'</h3>' => " ====\n",
'<h4>' => "=== ",
'</h4>' => " ===\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;
}

# 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(' ' x $indent_level . '- ');
}
elsif ($item_type eq 'text') {
# Dokuwiki has no "indent" without bullets or numbers, punt
$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('**: ')}


# 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::Dokuwiki - A class for creating Pod to Dokuwiki wiki filters.

=head1 SYNOPSIS

This module isn't used directly. Instead it is called via C<Pod::Simple::Wiki>:

#!/usr/bin/perl -w

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


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

...


Convert Pod to a Template wiki format using the installed C<pod2wiki> utility:

pod2wiki --style dokuwiki file.pod > file.wiki


=head1 DESCRIPTION

The C<Pod::Simple::Wiki::Dokuwiki> 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 Dokuwiki see: http://wiki.splitbrain.org/wiki:dokuwiki

This module isn't generally invoked directly. Instead it is called via C<Pod::Simple::Wiki>. See the L<Pod::Simple::Wiki> and L<pod2wiki> documentation for more information.


=head1 METHODS

Pod::Simple::Wiki::Dokuwiki inherits all of the methods of C<Pod::Simple> and C<Pod::Simple::Wiki>. See L<Pod::Simple> and L<Pod::Simple::Wiki> for more details.

=head1 Dokuwiki Specific information

Dokuwiki does not support indentation outside of pre-formatted blocks, except for bulleted lists, so indentation is represented by an unordered list.

=head1 SEE ALSO

This module also installs a C<pod2wiki> command line utility. See C<pod2wiki --help> for details.


=head1 DISCLAIMER OF WARRANTY

Please refer to the DISCLAIMER OF WARRANTY in L<Pod::Simple::Wiki>.


=head1 AUTHORS

John McNamara jmcnamara@cpan.org

Joe Cooper joe@virtualmin.com

=head1 COPYRIGHT

� MMIII-MMVIII, 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.
7 changes: 5 additions & 2 deletions lib/Pod/Simple/Wiki/Template.pm
Expand Up @@ -15,7 +15,7 @@ package Pod::Simple::Wiki::Template;
#
#
# Copyright 2003-2012, John McNamara, jmcnamara@cpan.org
#
# Copyright 2014, Jens Wilke, jewilke@cpan.org
# Documentation after __END__
#

Expand All @@ -27,7 +27,7 @@ use vars qw(@ISA $VERSION);


@ISA = qw(Pod::Simple::Wiki);
$VERSION = '0.15';
$VERSION = '0.16';

# Portme. Start with these tags.

Expand Down Expand Up @@ -69,6 +69,9 @@ sub new {
my $self = Pod::Simple::Wiki->new( 'wiki', @_ );
$self->{_tags} = $tags;

# The =for and =begin targets that we accept.
# $self->accept_targets (qw/html text comment/);

bless $self, $class;
return $self;
}
Expand Down