r36622 - in /branches/upstream/libhtml-wikiconverter-mediawiki-perl/current: Changes META.yml README lib/HTML/WikiConverter/MediaWiki.pm t/01-mediawiki.t
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Fri May 29 04:23:34 UTC 2009
Author: ryan52-guest
Date: Fri May 29 04:23:25 2009
New Revision: 36622
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=36622
Log:
[svn-upgrade] Integrating new upstream version, libhtml-wikiconverter-mediawiki-perl (0.59)
Modified:
branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/Changes
branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/META.yml
branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/README
branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/lib/HTML/WikiConverter/MediaWiki.pm
branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/t/01-mediawiki.t
Modified: branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/Changes?rev=36622&op=diff
==============================================================================
--- branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/Changes (original)
+++ branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/Changes Fri May 29 04:23:25 2009
@@ -1,4 +1,10 @@
# Change log for HTML::WikiConverter::MediaWiki
+
+version: 0.59
+date: 2009-05-29
+changes:
+ - (bug #46453) fix bug in which <nowiki> was triggered too often
+ - update readme documentation
version: 0.58
date: 2009-03-06
Modified: branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/META.yml?rev=36622&op=diff
==============================================================================
--- branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/META.yml (original)
+++ branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/META.yml Fri May 29 04:23:25 2009
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: HTML-WikiConverter-MediaWiki
-version: 0.58
+version: 0.59
abstract: Convert HTML to MediaWiki markup
author:
- David J. Iberri <diberri at cpan.org>
Modified: branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/README?rev=36622&op=diff
==============================================================================
--- branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/README (original)
+++ branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/README Fri May 29 04:23:25 2009
@@ -1,9 +1,8 @@
-HTML::WikiConverter::MediaWiki version 0.55
-===========================================
+HTML::WikiConverter::MediaWiki
+==============================
HTML::WikiConverter::MediaWiki adds the MediaWiki dialect to
-HTML::WikiConverter allowing the conversion of HTML to MediaWiki
-markup.
+HTML::WikiConverter allowing conversion from HTML to MediaWiki markup.
SYNOPSIS
@@ -19,17 +18,7 @@
There's also a web interface if you're so inclined:
- http://diberri.dyndns.org/wikipedia/html2wiki/
-
-CHANGES IN 0.55
-
- * Added 'preserve_templates' attribute
- * Added 'preserve_nowiki' attribute
-
-DEPENDENCIES
-
- * HTML::WikiConverter version 0.60
- * URI
+ http://toolserver.org/~diberri/cgi-bin/html2wiki/
INSTALLATION
@@ -63,7 +52,7 @@
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.
Modified: branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/lib/HTML/WikiConverter/MediaWiki.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/lib/HTML/WikiConverter/MediaWiki.pm?rev=36622&op=diff
==============================================================================
--- branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/lib/HTML/WikiConverter/MediaWiki.pm (original)
+++ branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/lib/HTML/WikiConverter/MediaWiki.pm Fri May 29 04:23:25 2009
@@ -6,7 +6,8 @@
use URI;
use File::Basename;
-our $VERSION = '0.58';
+use HTML::Tagset;
+our $VERSION = '0.59';
=head1 NAME
@@ -335,36 +336,75 @@
sub _wikitext_patterns {
my $self = shift;
+ # the caret in "qr/^/" seems redundant with "start_of_line" but both
+ # are necessary
my %wikitext_patterns = (
- italic => qr/''/,
- misc => qr/^(?:\*|\#|\;|\:|\=|\!|\|)/m,
- rule => qr/^----/m,
- table => qr/^\{\|/m,
- link => qr/\[\[/m,
- template => qr/{{/m,
+ misc => { pattern => qr/^(?:\*|\#|\;|\:|\=|\!|\|)/m, location => 'start_of_line' },
+ italic => { pattern => qr/''/, location => 'anywhere' },
+ rule => { pattern => qr/^----/m, location => 'start_of_line' },
+ table => { pattern => qr/^\{\|/m, location => 'start_of_line' },
+ link => { pattern => qr/\[\[/m, location => 'anywhere' },
+ template => { pattern => qr/{{/m, location => 'anywhere' },
);
delete $wikitext_patterns{template} if $self->preserve_templates;
-
- return values %wikitext_patterns;
+ return \%wikitext_patterns;
}
sub _nowiki_text {
my( $self, $node ) = @_;
+
my $text = defined $node->attr('text') ? $node->attr('text') : '';
-
- my $found_wikitext = 0;
- foreach my $pat ( $self->_wikitext_patterns ) {
- $found_wikitext++, last if $text =~ $pat;
- }
-
- if( $found_wikitext ) {
+ return unless $text;
+
+ my $wikitext_patterns = $self->_wikitext_patterns;
+ my $found_nowiki_text = 0;
+
+ ANYWHERE: {
+ my @anywhere_patterns =
+ map { $_->{pattern} } grep { $_->{location} eq 'anywhere' } values %$wikitext_patterns;
+
+ $found_nowiki_text++ if $self->_match( $text, \@anywhere_patterns );
+ };
+
+ START_OF_LINE: {
+ last if $found_nowiki_text;
+
+ my @sol_patterns =
+ map { $_->{pattern} } grep { $_->{location} eq 'start_of_line' } values %$wikitext_patterns;
+
+ # find closest parent that is a block-level node
+ my $nearest_parent_block = $self->elem_search_lineage( $node, { block => 1 } );
+
+ if( $nearest_parent_block ) {
+ my $leftmostish_text_node = $self->_get_leftmostish_text_node( $nearest_parent_block );
+ if( $leftmostish_text_node and $node == $leftmostish_text_node ) {
+ # I'm the first child in this block element, so let's apply start_of_line nowiki fixes
+ $found_nowiki_text++ if $self->_match( $text, \@sol_patterns );
+ }
+ }
+ };
+
+ if( $found_nowiki_text ) {
$text = "<nowiki>$text</nowiki>";
} else {
$text =~ s~(\[\b(?:$URL_PROTOCOLS):$EXT_LINK_URL_CLASS+ *$EXT_LINK_TEXT_CLASS*?\])~<nowiki>$1</nowiki>~go;
}
$node->attr( text => $text );
+}
+
+sub _get_leftmostish_text_node {
+ my( $self, $node ) = @_;
+ return unless $node;
+ return $node if $node->tag eq '~text';
+ return $self->_get_leftmostish_text_node( ($node->content_list)[0] )
+}
+
+sub _match {
+ my( $self, $text, $patterns ) = @_;
+ $text =~ $_ && return 1 for @$patterns;
+ return 0;
}
my %extra = (
Modified: branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/t/01-mediawiki.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/t/01-mediawiki.t?rev=36622&op=diff
==============================================================================
--- branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/t/01-mediawiki.t (original)
+++ branches/upstream/libhtml-wikiconverter-mediawiki-perl/current/t/01-mediawiki.t Fri May 29 04:23:25 2009
@@ -83,6 +83,42 @@
<p>[http://example.com]</p>
__W__
<nowiki>[http://example.com]</nowiki>
+__NEXT__
+(bug #46453) triggering <nowiki> too often
+__H__
+<em>x</em>:bla
+__W__
+''x'':bla
+__NEXT__
+do not add a <nowiki> tag only if offending character(s) occur at the beginning of text node
+__H__
+<p>text <strong>*</strong>
+<p>text <strong>#</strong>
+<p>text <strong>;</strong>
+<p>text <strong>:</strong>
+<p>text <strong>=</strong>
+<p>text <strong>!</strong>
+<p>text <strong>|</strong>
+<p>text <strong>----</strong>
+<p>text <strong>{|</strong>
+__W__
+text '''*'''
+
+text '''#'''
+
+text ''';'''
+
+text ''':'''
+
+text '''='''
+
+text '''!'''
+
+text '''|'''
+
+text '''----'''
+
+text '''{|'''
__NEXT__
tr attributes
__H__
@@ -783,3 +819,14 @@
<p><span style='font-size:40.0pt; font-family:"ArialNarrow"'>The Test Header</span></p>
__W__
<span style="font-size:40pt; font-family:ArialNarrow">The Test Header</span>
+__NEXT__
+(bug #29342) Tag attributes with 0 ::TODO("this is actually an H::WC-specific bug")
+__H__
+<table cellspacing="0" cellpadding="3" border="1">
+<tr><td>Hello</td><td>World</td></tr>
+</table>
+__W__
+{| border="1" cellpadding="3" cellspacing="0"
+| Hello
+| World
+|}
More information about the Pkg-perl-cvs-commits
mailing list