Skip Menu |

This queue is for tickets about the HTML-WikiConverter CPAN distribution.

Report information
The Basics
Id: 18287
Status: resolved
Worked: 15 min
Priority: 0/
Queue: HTML-WikiConverter

People
Owner: diberri [...] cpan.org
Requestors: anno [...] shroomery.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.52
Fixed in: (no value)



Subject: <br> tag problem in connection with new line in html code
When useing the converter to PmWiki dialect, the conversion of <br> is not done properly if followed by line break character in html code. Example: text<BR> text Converts to: text \\ text It should convert to: text \\ text The leading space causes a different markup in PmWiki.
From: anno [...] shroomery.org
I should clarify the example: Example: text<BR> text Converts to: text \\ <leading space>text It should convert to: text \\ text
On Wed Mar 22 06:48:49 2006, guest wrote: Show quoted text
> Example: > text<BR> > text > > Converts to: > text \\ > <leading space>text
Thanks for the report. I'm able to reproduce this on my system, which is a good start. The problem begins at the parse stage, with the HTML being parsed as follows (I used the words "line1" and "line2" instead of "text" in my example): <p> <~text text="line1"></~text> <br> <~text text=" line2"></~text> </p> Show quoted text
> It should convert to: > text \\ > text
I think this can be achieved by preprocessing the HTML using these rules: * If the node is a text node; * and if its left sibling is a <br>; * and if it is not contained within a <pre>; * then remove leading spaces from the text node Seems a bit clumsy, and in fact, my first thought was to simply fix things by changing PmWiki's paragraph line formatting from 'multi' to 'single'. That would've done the trick except that (AFAIK) PmWiki requires <br> to be converted into "\\<newline>"; since newlines are allowed inside PmWiki paragraphs, the line format must be 'multi' and not 'single'. Hence all the extra work as outlined in the steps above. Attached is a patch that implements the described fix. In addition, a patched version of the PmWiki is running on the web interface to H::WC at <http://diberri.dyndns.org/html2wiki.html>. Comments on this fix or suggestions regarding its improvement are much appreciated. If no problems are found, then I may release PmWiki 0.51 as soon as tonight. -- David Iberri
Index: lib/HTML/WikiConverter/PmWiki.pm =================================================================== RCS file: /usr/local/cvsroot/html2wiki/HTML-WikiConverter-PmWiki/lib/HTML/WikiConverter/PmWiki.pm,v retrieving revision 1.3 diff -u -r1.3 PmWiki.pm --- lib/HTML/WikiConverter/PmWiki.pm 2006/01/10 23:27:09 1.3 +++ lib/HTML/WikiConverter/PmWiki.pm 2006/03/22 12:58:53 @@ -151,6 +151,10 @@ my $tag = $node->tag || ''; $self->_move_aname($node) if $tag eq 'a' and $node->attr('name'); $self->caption2para($node) if $tag eq 'caption'; + if( $tag eq '~text' and $node->left and $node->left->tag and $node->left->tag eq 'br' and !$node->look_up(_tag => 'pre') ) { + ( my $text = $node->attr('text') ) =~ s/^\s+//; + $node->attr( text => $text ); + } } sub _move_aname {
From: anno [...] shroomery.org
Cool, thank you! I noticed some other (unrelated) things: <div align="center">center this text</div> doesn't get processed. And: <center>some text</center> converts to: @@some text@@ It should convert to: %center%some text
On Wed Mar 22 09:15:09 2006, guest wrote: Show quoted text
> I noticed some other (unrelated) things:
Being as these aren't related to the <br> problem that this ticket covers, can you please create a new ticket for these? Thanks! -- David Iberri
Subject: Re: [rt.cpan.org #18287] <br> tag problem in connection with new line in html code
Date: Wed, 22 Mar 2006 16:26:29 +0100
To: bug-HTML-WikiConverter [...] rt.cpan.org
From: Anno <anno [...] shroomery.org>
via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=18287 > > > On Wed Mar 22 09:15:09 2006, guest wrote: >
>> I noticed some other (unrelated) things: >>
> > Being as these aren't related to the <br> problem that this ticket > covers, can you please create a new ticket for these? Thanks! > > -- David Iberri > >
Sure. Oh, when I try to fetch this url: http://www.shroomery.org/glossary.php?ltr=all I get: *System error* *error:* The 'base_uri' parameter ("http://www.shroomery.org/glossary.php?ltr=all") to HTML::WikiConverter::__validate_attributes was a 'scalarref object', which is not one of the allowed types: scalar at /var/www/diberri/html/html2wiki.html line 104 *context:* *...* *265:* # whether they should generate a full stack trace (confess() and cluck()) *266:* # or simply report the caller's package (croak() and carp()), respectively. *267:* # confess() and croak() die, carp() and cluck() warn. *268:* *269:* sub croak { die shortmess @_ } *270:* sub confess { die longmess @_ } *271:* sub carp { warn shortmess @_ } *272:* sub cluck { warn longmess @_ } *273:* *...* *code stack:* /usr/local/lib/perl5/5.8.6/Carp.pm:269 /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm:414 /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm:110 /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm:94 /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm:103 /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm:89 /var/www/diberri/html/html2wiki.html:104 /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm:753 /var/www/diberri/mason/data/obj/html2wiki.html:32 raw error <http://diberri.dyndns.org/html2wiki.html#raw> The 'base_uri' parameter ("http://www.shroomery.org/glossary.php?ltr=all") to HTML::WikiConverter::__validate_attributes was a 'scalarref object', which is not one of the allowed types: scalar at /var/www/diberri/html/html2wiki.html line 104 Trace begun at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Exceptions.pm line 131 HTML::Mason::Exceptions::rethrow_exception('The \'base_uri\' parameter ("http://www.shroomery.org/glossary.php?ltr=all") to HTML::WikiConverter::__validate_attributes was a \'scalarref object\', which is not one of the allowed types: scalar^J at /var/www/diberri/html/html2wiki.html line 104^J') called at /usr/local/lib/perl5/5.8.6/Carp.pm line 269 Carp::croak('The \'base_uri\' parameter ("http://www.shroomery.org/glossary.php?ltr=all") to HTML::WikiConverter::__validate_attributes was a \'scalarref object\', which is not one of the allowed types: scalar^J') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm line 414 HTML::WikiConverter::__validate_attributes(undef, 'wiki_uri', '', 'dialect', 'PmWiki', 'base_uri', 'URI::http=SCALAR(0x9e801e4)', 'wrap_in_html', 1) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm line 110 HTML::WikiConverter::__setup('HTML::WikiConverter::PmWiki=HASH(0x9d31a50)', 'wiki_uri', '', 'dialect', 'PmWiki', 'base_uri', 'URI::http=SCALAR(0x9e801e4)', 'wrap_in_html', 1) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm line 94 HTML::WikiConverter::new('HTML::WikiConverter::PmWiki', 'wiki_uri', '', 'dialect', 'PmWiki', 'base_uri', 'URI::http=SCALAR(0x9e801e4)', 'wrap_in_html', 1) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm line 103 HTML::WikiConverter::__new_dialect('HTML::WikiConverter', 'dialect', 'PmWiki', 'base_uri', 'URI::http=SCALAR(0x9e801e4)', 'wiki_uri', '', 'wrap_in_html', 1) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/WikiConverter.pm line 89 HTML::WikiConverter::new('HTML::WikiConverter', 'dialect', 'PmWiki', 'base_uri', 'URI::http=SCALAR(0x9e801e4)', 'wiki_uri', '', 'wrap_in_html', 1) called at /var/www/diberri/html/html2wiki.html line 104 HTML::Mason::Commands::__ANON__('show_url_html', 'yes', 'show_parsed_html', 'yes', 'wiki_uri', '', 'html', '<span style="text-decoration: underline;">asdf</span><br>^M^J<span style="font-style: italic;">asdf</span><br>^M^J<span style="font-weight: bold;">asd</span><br>^M^J<span style="color: rgb(255, 0, 0);">asdf</span><br>', 'dialect', 'PmWiki', 'url', 'http://www.shroomery.org/glossary.php?ltr=all', 'base_uri', '', 'wiki', 'asdf \\^M^Jasdf \\^M^Jasd \\^M^Jasdf \\') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Component.pm line 158 HTML::Mason::Component::run_dynamic_sub('HTML::Mason::Component::FileBased=HASH(0x9d3426c)', 'main', 'show_url_html', 'yes', 'show_parsed_html', 'yes', 'wiki_uri', '', 'html', '<span style="text-decoration: underline;">asdf</span><br>^M^J<span style="font-style: italic;">asdf</span><br>^M^J<span style="font-weight: bold;">asd</span><br>^M^J<span style="color: rgb(255, 0, 0);">asdf</span><br>', 'dialect', 'PmWiki', 'url', 'http://www.shroomery.org/glossary.php?ltr=all', 'base_uri', '', 'wiki', 'asdf \\^M^Jasdf \\^M^Jasd \\^M^Jasdf \\') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 753 HTML::Mason::Request::call_dynamic('HTML::Mason::Request::ApacheHandler=HASH(0x9a4ffa4)', 'main', 'show_url_html', 'yes', 'show_parsed_html', 'yes', 'wiki_uri', '', 'html', '<span style="text-decoration: underline;">asdf</span><br>^M^J<span style="font-style: italic;">asdf</span><br>^M^J<span style="font-weight: bold;">asd</span><br>^M^J<span style="color: rgb(255, 0, 0);">asdf</span><br>', 'dialect', 'PmWiki', 'url', 'http://www.shroomery.org/glossary.php?ltr=all', 'base_uri', '', 'wiki', 'asdf \\^M^Jasdf \\^M^Jasd \\^M^Jasdf \\') called at /var/www/diberri/mason/data/obj/html2wiki.html line 32 HTML::Mason::Commands::__ANON__('show_url_html', 'yes', 'show_parsed_html', 'yes', 'wiki_uri', '', 'html', '<span style="text-decoration: underline;">asdf</span><br>^M^J<span style="font-style: italic;">asdf</span><br>^M^J<span style="font-weight: bold;">asd</span><br>^M^J<span style="color: rgb(255, 0, 0);">asdf</span><br>', 'dialect', 'PmWiki', 'url', 'http://www.shroomery.org/glossary.php?ltr=all', 'base_uri', '', 'wiki', 'asdf \\^M^Jasdf \\^M^Jasd \\^M^Jasdf \\') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Component.pm line 136 HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x9d3426c)', 'show_url_html', 'yes', 'show_parsed_html', 'yes', 'wiki_uri', '', 'html', '<span style="text-decoration: underline;">asdf</span><br>^M^J<span style="font-style: italic;">asdf</span><br>^M^J<span style="font-weight: bold;">asd</span><br>^M^J<span style="color: rgb(255, 0, 0);">asdf</span><br>', 'dialect', 'PmWiki', 'url', 'http://www.shroomery.org/glossary.php?ltr=all', 'base_uri', '', 'wiki', 'asdf \\^M^Jasdf \\^M^Jasd \\^M^Jasdf \\') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 1069 eval {...} at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 1068 HTML::Mason::Request::comp(undef, undef, undef, 'show_url_html', 'yes', 'show_parsed_html', 'yes', 'wiki_uri', '', 'html', '<span style="text-decoration: underline;">asdf</span><br>^M^J<span style="font-style: italic;">asdf</span><br>^M^J<span style="font-weight: bold;">asd</span><br>^M^J<span style="color: rgb(255, 0, 0);">asdf</span><br>', 'dialect', 'PmWiki', 'url', 'http://www.shroomery.org/glossary.php?ltr=all', 'base_uri', '', 'wiki', 'asdf \\^M^Jasdf \\^M^Jasd \\^M^Jasdf \\') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 338 eval {...} at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 338 eval {...} at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 297 HTML::Mason::Request::exec('HTML::Mason::Request::ApacheHandler=HASH(0x9a4ffa4)') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/ApacheHandler.pm line 134 eval {...} at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/ApacheHandler.pm line 134 HTML::Mason::Request::ApacheHandler::exec('HTML::Mason::Request::ApacheHandler=HASH(0x9a4ffa4)') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/ApacheHandler.pm line 827 HTML::Mason::ApacheHandler::handle_request('HTML::Mason::ApacheHandler=HASH(0x8b1fe00)', 'Apache=SCALAR(0x9d31948)') called at (eval 29) line 8 HTML::Mason::ApacheHandler::handler('HTML::Mason::ApacheHandler', 'Apache=SCALAR(0x9d31948)') called at /dev/null line 0 eval {...} at /dev/null line 0 Kind Regards, Anno

Message body is not shown because it is too large.

On Wed Mar 22 10:26:45 2006, anno@shroomery.org wrote: Show quoted text
> Oh, when I try to fetch this url: > http://www.shroomery.org/glossary.php?ltr=all > > I get: > > *System error* > > *error:* The 'base_uri' parameter > ("http://www.shroomery.org/glossary.php?ltr=all") to > HTML::WikiConverter::__validate_attributes was a 'scalarref object', > which is not one of the allowed types: scalar > at /var/www/diberri/html/html2wiki.html line 104
This was a bug in the web interface. Thanks for catching it; it's now fixed. -- David Iberri