diff options
author | Ryan Niebur <ryan@debian.org> | 2008-12-02 05:50:43 +0000 |
---|---|---|
committer | Ryan Niebur <ryan@debian.org> | 2008-12-02 05:50:43 +0000 |
commit | a7a475cb99665c2599998351e2ec2fbbf801f5ed (patch) | |
tree | e4f6c60f5abe751968b00bca130eefadd1fc10ec | |
parent | c487b37fe0e7f1a5b823a5de7a3cbbd0bb2ea7a0 (diff) |
[svn-upgrade] Integrating new upstream version, libhtml-wikiconverter-moinmoin-perl (0.54)
-rw-r--r-- | Changes | 15 | ||||
-rw-r--r-- | META.yml | 35 | ||||
-rw-r--r-- | Makefile.PL | 3 | ||||
-rw-r--r-- | README | 15 | ||||
-rw-r--r-- | lib/HTML/WikiConverter/MoinMoin.pm | 64 | ||||
-rw-r--r-- | t/moinmoin.t | 29 | ||||
-rw-r--r-- | t/pod-coverage.t | 1 | ||||
-rw-r--r-- | t/runtests.pl | 30 |
8 files changed, 117 insertions, 75 deletions
@@ -1,23 +1,30 @@ # Change log for HTML::WikiConverter::MoinMoin +version: 0.54 +date: 2008-10-16 +changes: + - (bug #40114) fix '=' counts in section headings + - (bug #29347) support anchors with content + - require H::WC 0.63, latest + version: 0.53 -date: Thu Jul 20 19:00:00 EST 2006 +date: 2006-07-20 changes: - add attribute types - require Params::Validate - require HTML::WikiConverter 0.60 version: 0.52 -date: Wed June 07 15:00:00 EST 2006 +date: 2006-07-07 changes: - (bug #17813) implement anchors version: 0.51 -date: Tue Mar 21 2006 +date: 2006-03-21 changes: - (bug #18083) fix tests that used 'strip_comments' attribute, which no longer exists version: 0.50 -date: Tue Jan 10 2006 +date: 2006-01-10 changes: - branched from main HTML::WikiConverter codebase. @@ -1,14 +1,23 @@ -# http://module-build.sourceforge.net/META-spec.html -#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# -name: HTML-WikiConverter-MoinMoin -version: 0.53 -version_from: lib/HTML/WikiConverter/MoinMoin.pm -installdirs: site +--- #YAML:1.0 +name: HTML-WikiConverter-MoinMoin +version: 0.54 +abstract: Convert HTML to MoinMoin markup +author: + - David J. Iberri <diberri@cpan.org> +license: perl +distribution_type: module +configure_requires: + ExtUtils::MakeMaker: 0 requires: - HTML::WikiConverter: 0.5 - Params::Validate: 0 - Test::More: 0 - URI: 0 - -distribution_type: module -generated_by: ExtUtils::MakeMaker version 6.17 + HTML::WikiConverter: 0.63 + Params::Validate: 0 + Test::More: 0 + URI: 0 +no_index: + directory: + - t + - inc +generated_by: ExtUtils::MakeMaker version 6.48 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 diff --git a/Makefile.PL b/Makefile.PL index 2c5bb82..d2bab98 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -5,12 +5,13 @@ use ExtUtils::MakeMaker; WriteMakefile( NAME => 'HTML::WikiConverter::MoinMoin', AUTHOR => 'David J. Iberri <diberri@cpan.org>', + LICENSE => 'perl', VERSION_FROM => 'lib/HTML/WikiConverter/MoinMoin.pm', ABSTRACT_FROM => 'lib/HTML/WikiConverter/MoinMoin.pm', PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, - 'HTML::WikiConverter' => 0.50, + 'HTML::WikiConverter' => 0.63, 'Params::Validate' => 0, 'URI' => 0, }, @@ -21,19 +21,6 @@ There's also a web interface if you're so inclined: http://diberri.dyndns.org/wikipedia/html2wiki/ -CHANGES IN 0.53 - - * Update for HTML::WikiConverter 0.60 - -INSTALLATION - -To install this module, run the following commands: - - perl Makefile.PL - make - make test - make install - SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the @@ -57,7 +44,7 @@ You can also look for information at: COPYRIGHT AND LICENCE -Copyright (C) 2006 David J. Iberri +Copyright (c) David J. Iberri This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/HTML/WikiConverter/MoinMoin.pm b/lib/HTML/WikiConverter/MoinMoin.pm index 6ffdd97..fe7b972 100644 --- a/lib/HTML/WikiConverter/MoinMoin.pm +++ b/lib/HTML/WikiConverter/MoinMoin.pm @@ -4,7 +4,7 @@ use warnings; use strict; use base 'HTML::WikiConverter'; -our $VERSION = '0.53'; +our $VERSION = '0.54'; use Params::Validate ':types'; use URI; @@ -63,16 +63,15 @@ sub rules { tr => { end => "||\n", line_format => 'single' }, td => { start => \&_td_start, end => ' ', trim => 'both' }, th => { alias => 'td' }, - ); - # Headings (h1-h6) - my @headings = ( 1..6 ); - foreach my $level ( @headings ) { - my $tag = "h$level"; - my $affix = ( '=' ) x ($level+1); - $affix = '======' if $level == 6; - $rules{$tag} = { start => $affix.' ', end => ' '.$affix, block => 1, trim => 'both', line_format => 'single' }; - } + # (bug #40114) http://moinmo.in/HelpOnHeadlines + h1 => { start => '= ', end => ' =', block => 1, trim => 'both', line_format => 'single' }, + h2 => { start => '== ', end => ' ==', block => 1, trim => 'both', line_format => 'single' }, + h3 => { start => '=== ', end => ' ===', block => 1, trim => 'both', line_format => 'single' }, + h4 => { start => '==== ', end => ' ====', block => 1, trim => 'both', line_format => 'single' }, + h5 => { start => '===== ', end => ' =====', block => 1, trim => 'both', line_format => 'single' }, + h6 => { start => '====== ', end => ' ======', block => 1, trim => 'both', line_format => 'single' }, + ); return \%rules; } @@ -151,20 +150,24 @@ sub _li_start { sub _link { my( $self, $node, $rules ) = @_; - # (bug #17813) - my $name = $node->attr('name'); - return sprintf '[[Anchor(%s)]]', $name if $self->enable_anchor_macro and $name; + # bug #17813 requests anchors; MoinMoin:HelpOnMacros gives new + # "<<Anchor(name)>>" syntax for anchors and other macros (this was + # previously "[[Anchor(name)]]" sometime prior to 2008-10-01) + + # bug #29347 requests 'id' be favored over 'name' + my $anchor_name = $node->attr('id') || $node->attr('name'); + return sprintf( "<<Anchor(%s)>>\n", $anchor_name ) if $self->enable_anchor_macro and $anchor_name; my $url = $node->attr('href') || ''; my $text = $self->get_elem_contents($node) || ''; - # (bug #17813) + # bug #17813 if( $self->_abs2rel($url) =~ /^#/ ) { $url = $self->_abs2rel($url); } return $url if $url eq $text; - return "[$url $text]"; + return "[[$url|$text]]"; } sub _abs2rel { @@ -180,23 +183,24 @@ sub _image { sub preprocess_node { my( $self, $node ) = @_; - $self->strip_aname($node) if $node->tag eq 'a'; - $self->caption2para($node) if $node->tag eq 'caption'; - - # (bug #17813) - if( $node->tag eq 'a' and $node->attr('name') ) { - my $name = $node->attr('name'); - $node->preinsert( new HTML::Element('a', name => $name) ); - $node->attr( name => undef ); - } + my $tag = $node->tag || ''; + + $self->caption2para($node) if $tag eq 'caption'; + + # Find something like <a id="some anchor here" name="or here">and content here</a> + if( $node->tag eq 'a' and ( $node->attr('name') or $node->attr('id') ) and !$node->attr('href') and $self->get_elem_contents($node) ) { + my $anchor_name = $node->attr('id') || $node->attr('name'); + $node->preinsert( new HTML::Element('a', name => $anchor_name) ); + $node->replace_with_content->delete(); + } } my @protocols = qw( http https mailto ); -my $urls = '(' . join('|', @protocols) . ')'; -my $ltrs = '\w'; -my $gunk = '\/\#\~\:\.\?\+\=\&\%\@\!\-'; -my $punc = '\.\:\?\-\{\(\)\}'; -my $any = "${ltrs}${gunk}${punc}"; +my $urls = '(' . join('|', @protocols) . ')'; +my $ltrs = '\w'; +my $gunk = '\/\#\~\:\.\?\+\=\&\%\@\!\-'; +my $punc = '\.\:\?\-\{\(\)\}'; +my $any = "${ltrs}${gunk}${punc}"; my $url_re = "\\b($urls:\[$any\]+?)(?=\[$punc\]*\[^$any\])"; sub postprocess_output { @@ -247,7 +251,7 @@ L<http://search.cpan.org/dist/HTML-WikiConverter-MoinMoin> =head1 COPYRIGHT & LICENSE -Copyright 2006 David J. Iberri, all rights reserved. +Copyright (c) David J. Iberri, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/t/moinmoin.t b/t/moinmoin.t index 0493604..1457a52 100644 --- a/t/moinmoin.t +++ b/t/moinmoin.t @@ -15,7 +15,7 @@ __H__ <a href="http://google.com">GOOGLE</a><br/> NewLine __W__ -[http://google.com GOOGLE][[BR]] NewLine +[[http://google.com|GOOGLE]][[BR]] NewLine __NEXT__ bold __H__ @@ -160,31 +160,31 @@ h1 __H__ <h1>h1</h1> __W__ -== h1 == += h1 = __NEXT__ h2 __H__ <h2>h2</h2> __W__ -=== h2 === +== h2 == __NEXT__ h3 __H__ <h3>h3</h3> __W__ -==== h3 ==== +=== h3 === __NEXT__ h4 __H__ <h4>h4</h4> __W__ -===== h4 ===== +==== h4 ==== __NEXT__ h5 __H__ <h5>h5</h5> __W__ -====== h5 ====== +===== h5 ===== __NEXT__ h6 __H__ @@ -202,7 +202,7 @@ external links __H__ <html><a href="test.html">thing</a></html> __W__ -[http://www.test.com/test.html thing] +[[http://www.test.com/test.html|thing]] __NEXT__ external link (plain) __H__ @@ -239,8 +239,19 @@ __W__ ||<-2 tablestyle="width:100%; background-color:white" id="thing"> thing || || next ||<id="crazy"> crazy || __NEXT__ +anchors with content (bug #29347) ::enable_anchor_macro(1) +__H__ +<a id="top">This is the top of the page</a> +__W__ +<<Anchor(top)>> +This is the top of the page +__NEXT__ anchors (bug #17813) ::enable_anchor_macro(1) __H__ -<p><a name="here" href="#here">here</a></p> +<a id="id-top" name="name-top"></a> + +<p><a href="#href-top">Top of page</a></p> __W__ -[[Anchor(here)]][#here here] +<<Anchor(id-top)>> + +[[#href-top|Top of page]] diff --git a/t/pod-coverage.t b/t/pod-coverage.t index 16c6bbf..990ade6 100644 --- a/t/pod-coverage.t +++ b/t/pod-coverage.t @@ -9,6 +9,7 @@ all_pod_coverage_ok( { also_private => [ get_elem_contents |get_wiki_page |get_attr_str + |elem_within_block |is_camel_case |rule |rules diff --git a/t/runtests.pl b/t/runtests.pl index af8c981..d4755a1 100644 --- a/t/runtests.pl +++ b/t/runtests.pl @@ -76,15 +76,37 @@ sub runtests { my( $html, $wiki ) = split /__W__\n/, $test; $html =~ s/__H__\n//; +# $name =~ s{\s*\:\:(\w+\([^\)]*?\))}{ +# my $method_call = $1; +# eval "\$wc->$method_call;"; +# die "Failed test call ($name): $@" if $@; +# ''; +# }ge; + + my( $todo, $todo_reason ); $name =~ s{\s*\:\:(\w+\([^\)]*?\))}{ - my $method_call = $1; - eval "\$wc->$method_call;"; - die "Failed test call ($name): $@" if $@; + my $keyword = $1; + if( $keyword =~ /TODO\((\"|\')(.*?)\1/ ) { + $todo = 1; + $todo_reason = $2; + } else { + my $method_call = $keyword; + eval "\$wc->$method_call;"; + die "Failed test call ($name): $@" if $@; + } ''; }ge; for( $html, $wiki ) { s/^\n+//; s/\n+$// } - is( $wc->html2wiki($html), $wiki, $name ); + + if( $todo ) { + TODO: { + local $TODO = $todo_reason; + is( $wc->html2wiki($html), $wiki, $name ); + } + } else { + is( $wc->html2wiki($html), $wiki, $name ); + } } #file_test($wc) unless $minimal; |