From 4aeca486d8f938a2b9ddf289cd3b5e8fbe45beec Mon Sep 17 00:00:00 2001 From: David Iberri Date: Mon, 16 Mar 2009 19:45:31 -0800 Subject: [PATCH] import HTML-WikiConverter 0.67 from CPAN git-cpan-module: HTML-WikiConverter git-cpan-version: 0.67 git-cpan-authorid: DIBERRI git-cpan-file: authors/id/D/DI/DIBERRI/HTML-WikiConverter-0.67.tar.gz --- Changes | 10 ++++++++++ META.yml | 2 +- README | 3 ++- cgi/templates/main.html | 2 -- lib/HTML/WikiConverter.pm | 16 ++++++++++++---- webapp-install | 17 ++++++++++++----- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/Changes b/Changes index 512f404..fe4ad99 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,15 @@ # Change log for HTML::WikiConverter +version: 0.67 +date: 2009-03-16 +changes: + - add 'p_strict' attribute for enabling/disabling + HTML::TreeBuilder's p_strict option (enabled by default) -- this + was done for the Markdown dialect, specifically for bug #43997 + - mention XML::Writer requirement in README if cgi app is installed + - webapp-install script creates webapp directory if necessary + - miscellaneous minor code cleanup + version: 0.66 date: 2009-03-07 changes: diff --git a/META.yml b/META.yml index d7ca1c1..8d52e50 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name: HTML-WikiConverter -version: 0.66 +version: 0.67 abstract: Convert HTML to wiki markup author: - David J. Iberri diff --git a/README b/README index 0710f72..e5e08cc 100644 --- a/README +++ b/README @@ -77,7 +77,8 @@ The following are required for a basic installation: * HTML::Element * CSS -CGI::Application is required if you will be using the installed web +CGI::Application and XML::Writer (sorry -- I'll make it optional in a +future release) are required if you will be using the installed web application, HTML::WikiConverter::WebApp. BUGS diff --git a/cgi/templates/main.html b/cgi/templates/main.html index e99f488..18c8364 100644 --- a/cgi/templates/main.html +++ b/cgi/templates/main.html @@ -12,8 +12,6 @@
- -

HTML-to-wiki converter

diff --git a/lib/HTML/WikiConverter.pm b/lib/HTML/WikiConverter.pm index 9a5586a..3a2ae56 100644 --- a/lib/HTML/WikiConverter.pm +++ b/lib/HTML/WikiConverter.pm @@ -15,7 +15,7 @@ use Carp; use URI::Escape; use URI; -our $VERSION = '0.66'; +our $VERSION = '0.67'; our $AUTOLOAD; =head1 NAME @@ -225,7 +225,7 @@ sub html2wiki { my $tree = new HTML::TreeBuilder(); $tree->store_comments(1); - $tree->p_strict(1); + $tree->p_strict( $self->p_strict ); $tree->implicit_body_p_tag(1); $tree->ignore_unknown(0); # et al @@ -296,7 +296,7 @@ sub __wikify { # Unspecified tags have their whitespace preserved (this allows # 'html' and 'body' tags [among others] to keep formatting when # inner tags like 'pre' need to preserve whitespace). - my $trim = exists $rules->{trim} ? $rules->{trim} : 'none'; # can't this just be $rules->{trim} || 'none'? + my $trim = $rules->{trim} || 'none'; $output =~ s/^\s+// if $trim eq 'both' or $trim eq 'leading'; $output =~ s/\s+$// if $trim eq 'both' or $trim eq 'trailing'; @@ -421,7 +421,7 @@ sub __preprocess_tree { $self->__rm_invalid_text($node); $node->delete, next if $self->strip_empty_tags and !$allowedEmptyTag{$node->tag} and $self->__elem_is_empty($node); $self->__encode_entities($node) if $node->tag eq '~text' and $self->escape_entities; - $self->__rel2abs($node) if $self->base_uri and $rel2abs{$node->tag}; + $self->__rel2abs($node) if $self->base_uri and exists $rel2abs{$node->tag}; $self->preprocess_node($node); } @@ -809,6 +809,13 @@ Passing C a true value uses L to encode potentially unsafe 'E', 'E', and 'E' characters. Defaults to true. +=head2 p_strict + +Boolean indicating whether L will use strict +handling of paragraph tags when parsing HTML input. (This corresponds +to the C method in the L module.) Enabled +by default. + =head2 passthrough_naked_tags Boolean indicating whether tags with no attributes ("naked" tags) @@ -915,6 +922,7 @@ sub __default_attribute_specs { { encoding => { type => SCALAR, default => 'utf-8' }, escape_entities => { type => BOOLEAN, default => 1 }, normalize => { type => BOOLEAN, default => 1 }, + p_strict => { type => BOOLEAN, default => 1 }, preprocess => { type => CODEREF | UNDEF, default => undef }, strip_empty_tags => { type => BOOLEAN, default => 0 }, slurp => { type => BOOLEAN, default => 0 }, diff --git a/webapp-install b/webapp-install index 04855e0..e8fc893 100755 --- a/webapp-install +++ b/webapp-install @@ -6,13 +6,17 @@ use Sys::Hostname; use File::Spec; my $host = hostname(); -my $default_webapp_dir = $host =~ /habitatoc/ - ? '/var/www/diberri/cgi-bin/html2wiki' - : $host =~ /Schonlein/ - ? '/Users/diberri/Sites/cgi-bin/html2wiki' - : ''; +my $default_webapp_dir = + $host =~ /habitatoc/ + ? '/var/www/diberri/cgi-bin/html2wiki' + : $host =~ /Schonlein/ + ? '/Users/diberri/Sites/cgi-bin/html2wiki' + : ''; my $webapp_dir = prompt( 'Path to web application:', $default_webapp_dir ); +die "no path specified" unless $webapp_dir; + +doit( "mkdir -p $webapp_dir" ) if ! -d $webapp_dir; doit( "cp -R cgi/* $webapp_dir" ); my $index_cgi = File::Spec->catfile( $webapp_dir, 'index.cgi' ); @@ -36,5 +40,8 @@ sub prompt { printf( '%s [%s]: ', $prompt, $default ); chomp( my $input = ); + $input =~ s/^\s+//; + $input =~ s/\s+$//; + return $input || $default || ''; }