Skip to content

Commit

Permalink
import HTML-WikiConverter 0.67 from CPAN
Browse files Browse the repository at this point in the history
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
  • Loading branch information
David Iberri authored and schwern committed Dec 12, 2009
1 parent 18250b5 commit 4aeca48
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
10 changes: 10 additions & 0 deletions 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:
Expand Down
2 changes: 1 addition & 1 deletion 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 <diberri@cpan.org>
Expand Down
3 changes: 2 additions & 1 deletion README
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions cgi/templates/main.html
Expand Up @@ -12,8 +12,6 @@
<body>
<div id="wrapper">

<!-- FIXME_TMPL_INCLUDE name="notes_donate.html" -->

<h1>HTML-to-wiki converter</h1>

<TMPL_IF name="error">
Expand Down
16 changes: 12 additions & 4 deletions lib/HTML/WikiConverter.pm
Expand Up @@ -15,7 +15,7 @@ use Carp;
use URI::Escape;
use URI;

our $VERSION = '0.66';
our $VERSION = '0.67';
our $AUTOLOAD;

=head1 NAME
Expand Down Expand Up @@ -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); # <ruby> et al

Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -809,6 +809,13 @@ Passing C<escape_entities> a true value uses L<HTML::Entities> to
encode potentially unsafe 'E<lt>', 'E<gt>', and 'E<amp>' characters.
Defaults to true.
=head2 p_strict
Boolean indicating whether L<HTML::TreeBuilder> will use strict
handling of paragraph tags when parsing HTML input. (This corresponds
to the C<p_strict> method in the L<HTML::TreeBuilder> module.) Enabled
by default.
=head2 passthrough_naked_tags
Boolean indicating whether tags with no attributes ("naked" tags)
Expand Down Expand Up @@ -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 },
Expand Down
17 changes: 12 additions & 5 deletions webapp-install
Expand Up @@ -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' );
Expand All @@ -36,5 +40,8 @@ sub prompt {

printf( '%s [%s]: ', $prompt, $default );
chomp( my $input = <STDIN> );
$input =~ s/^\s+//;
$input =~ s/\s+$//;

return $input || $default || '';
}

0 comments on commit 4aeca48

Please sign in to comment.