diff options
| author | fukachan <fukachan> | 2012-02-25 06:58:37 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2012-02-25 06:58:37 +0000 |
| commit | fb8f5305170640cdad168678a2b3925a29cc80bb (patch) | |
| tree | e41754a3f50b4422145b16c1c0d4d1889f9c89bd | |
| parent | 31ce5f2ebfc2eeaab0b4ef0c9c4a1d2ff14366d2 (diff) | |
| download | fml8-fb8f5305170640cdad168678a2b3925a29cc80bb.tar.gz fml8-fb8f5305170640cdad168678a2b3925a29cc80bb.tar.bz2 fml8-fb8f5305170640cdad168678a2b3925a29cc80bb.zip | |
Initial revision
| -rw-r--r-- | cpan/dist/HTML-FromText/Changes | 54 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/MANIFEST.SKIP | 8 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/META.yml | 16 | ||||
| -rwxr-xr-x | cpan/dist/HTML-FromText/bin/text2html | 89 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/ext/emacs-macros.el | 23 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/lib/HTML/FromText.pm | 846 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/t/01_features.t | 296 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/t/02_v2.01.t | 109 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/t/03_v2.02.t | 29 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/t/04_v2.03.t | 68 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/t/05_v2.04.t | 3 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/t/06_v2.05.t | 25 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/t/99_pod.t | 34 | ||||
| -rw-r--r-- | cpan/dist/HTML-FromText/t/files/paras.txt | 3 |
14 files changed, 1603 insertions, 0 deletions
diff --git a/cpan/dist/HTML-FromText/Changes b/cpan/dist/HTML-FromText/Changes new file mode 100644 index 00000000..d33e58c1 --- /dev/null +++ b/cpan/dist/HTML-FromText/Changes @@ -0,0 +1,54 @@ +2.05 + + - blockparas uses <p> as its inner tag, instead of <div> + - blockparas and blockcode are consolidated when they are found in + groups. blocklines are left out because they're so literal. + +2.04 + + - Fixed bug when run under 5.8.1 and always-random hashes. + - Emacs macros enhanced. + +2.03 + + - Working toward standards compliance. + - blockcode now uses pre tags. + - blockparas and blockquotes use div tags. + - Remove dependency on Regexp::Common. + - XHTML 1.1 valid output. + - CSS Class names for every option type. + - Fixed a but in tables where duplicate breakpoints were being + entered (reported by Dan Wright). + - Fixed but in tables where breakpoints of two spaces were ignored. + - text2html command line utility ensures output ends in newline. + - Add example emacs macros for modifying regions with text2html. + +2.02 + + - Added command line utility called 'text2html'. It will be + installed when this version of HTML::FromText is built and + installed. + - Fixed but in blockcode, wasn't preserving spaces. + +2.01 + + - Fixed URLS, they were broken because Regexp::Common::URI was much + too restrictive (reported by Wim Kerkhoff). + - Fixed bullets. Mixing '*' and '-' were previously allowed and caused + problems. They can't be mixed within paragraphs that are bulleted + lists any longer (reported by Wim Kerkhoff). + - Fixed bold and underline, they were broken and matching, but not + substituting, across line boundaries. They no longer match across + line boundaries (reported by Wim Kerkhoff). + - Fixed bold and underline, they were too greedy. Now they require + some non-word character before and after them (or the beginning or + ending of a line). (reported by Wim Kerkhoff). + - Nasty bug in lists where a nested list can cause an infinite loop + when bullets don't line up quite right vertically (reported by Wim + Kerkhoff). + +2.00 + + - Initial release as complete rewrite of version 1.005 by GDR. + - Inadvertently created a new feature, nested bulleted and + numbered lists. diff --git a/cpan/dist/HTML-FromText/MANIFEST.SKIP b/cpan/dist/HTML-FromText/MANIFEST.SKIP new file mode 100644 index 00000000..8184c80a --- /dev/null +++ b/cpan/dist/HTML-FromText/MANIFEST.SKIP @@ -0,0 +1,8 @@ +^blib/ +^Makefile$ +^Makefile\.old$ +^MANIFEST\.bak$ +^TODO$ +^pm_to_blib$ +.*~ +CVS diff --git a/cpan/dist/HTML-FromText/META.yml b/cpan/dist/HTML-FromText/META.yml new file mode 100644 index 00000000..fd0b084b --- /dev/null +++ b/cpan/dist/HTML-FromText/META.yml @@ -0,0 +1,16 @@ +# http://module-build.sourceforge.net/META-spec.html +#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# +name: HTML-FromText +version: 2.05 +version_from: lib/HTML/FromText.pm +installdirs: site +requires: + Email::Find::addrspec: 0.09 + Exporter::Lite: 0.01 + HTML::Entities: 1.26 + Scalar::Util: 1.12 + Test::More: 0.47 + Text::Tabs: 98.1128 + +distribution_type: module +generated_by: ExtUtils::MakeMaker version 6.17 diff --git a/cpan/dist/HTML-FromText/bin/text2html b/cpan/dist/HTML-FromText/bin/text2html new file mode 100755 index 00000000..65314c8b --- /dev/null +++ b/cpan/dist/HTML-FromText/bin/text2html @@ -0,0 +1,89 @@ +#!/usr/bin/perl +# -*- cperl -*- +use HTML::FromText; + +my %options, @files; + +my $options_done = 0; +while ( $_ = shift @ARGV ) { + if ( /^--\w/ && ! $options_done ) { + s/^--//; + my ($option, $val) = split /=/, $_, 2; + $val = 1 unless defined $val; + $options{$option} = $val; + } elsif ( /^--$/ ) { + $options_done = 1; + } else { + push @files, $_; + } +} + +@ARGV = @files; + +my $html = text2html + do {undef $/; <>}, + %options; + +$html .= "\n" unless $html =~ /\n$/; + +print $html; + +exit 0; + +__END__ + +=head1 NAME + +B<text2html> - Convert plain text to HTML + +=head1 SYNOPSIS + +B<text2html [options...]> [file ...] + +=head1 DESCRIPTION + +The C<text2html> utility converts text to HTML. Text can come from +standard input or files listed on the command line. + +The available options are outlined in L<HTML::FromText>. The option +syntax is slightly different. Options are prefixed with two dashes +(C<-->) and may have an option value following an equals sign (C<=>). +The default value is on (<1>). + +=head1 EXAMPLES + +Convert the C<README> file using C<paras> and C<blockcode>. + + text2html --paras --blockcode README + +Convert a file called C<--stupid-name>. + + text2html --paras -- --stupid-name + +Convert text on standard input. + + text2html --paras --urls --email --bold --underline + +Convert text on standard input but turn off C<metachars>. + + text2html --metachars=0 --lines + +=head1 DIAGNOSTICS + +The C<text2html> utility exits 0 on success, and >0 if an error occurs. + +=head1 SEE ALSO + +L<perl(1)>, L<HTML::FromText(3)>. + +=head1 AUTHOR + +Casey West <F<casey@geeknest.com>>. + +=head1 COPYRIGHT + + Copyright (c) 2003 Casey West. All rights reserved. This module is + free software; you can redistribute it and/or modify it under the same + terms as Perl itself. + +=cut diff --git a/cpan/dist/HTML-FromText/ext/emacs-macros.el b/cpan/dist/HTML-FromText/ext/emacs-macros.el new file mode 100644 index 00000000..a456adf2 --- /dev/null +++ b/cpan/dist/HTML-FromText/ext/emacs-macros.el @@ -0,0 +1,23 @@ +;; blockquotes +(global-set-key (kbd "C-c h") + (lambda () (interactive) + (shell-command-on-region + (region-beginning) (region-end) + "text2html --paras --urls --blockquotes --email --bullets --numbers --tables --bold --underline" + (current-buffer) t))) + +;; blockparas +(global-set-key (kbd "C-c j") + (lambda () (interactive) + (shell-command-on-region + (region-beginning) (region-end) + "text2html --paras --urls --blockparas --email --bullets --numbers --tables --bold --underline" + (current-buffer) t))) + +;; blockcode +(global-set-key (kbd "C-c k") + (lambda () (interactive) + (shell-command-on-region + (region-beginning) (region-end) + "text2html --paras --urls --blockcode --email --bullets --numbers --tables --bold --underline" + (current-buffer) t))) diff --git a/cpan/dist/HTML-FromText/lib/HTML/FromText.pm b/cpan/dist/HTML-FromText/lib/HTML/FromText.pm new file mode 100644 index 00000000..03ce219e --- /dev/null +++ b/cpan/dist/HTML-FromText/lib/HTML/FromText.pm @@ -0,0 +1,846 @@ +package HTML::FromText; + +=head1 NAME + +HTML::FromText - Convert plain text to HTML. + +=head1 SYNOPSIS + + use HTML::FromText; + text2html( $text, %options ); + + # or + + use HTML::FromText (); + my $t2h = HTML::FromText->new( \%options ); + my $html = $t2h->parse( $html ); + +=cut + +use strict; +use Scalar::Util qw[blessed]; +use HTML::Entities qw[encode_entities]; +use Text::Tabs qw[expand]; +use Email::Find::addrspec qw[$Addr_spec_re]; +use Exporter::Lite; + +use vars qw[$VERSION @EXPORT @DECORATORS $PROTOCOLS]; + +$VERSION = '2.05'; +@EXPORT = qw[text2html]; +@DECORATORS = qw[urls email bold underline]; +$PROTOCOLS = qr/ + afs | cid | ftp | gopher | + http | https | mid | news | + nntp | prospero | telnet | wais + /x; + +=head1 DESCRIPTION + +C<HTML::FromText> converts plain text to HTML. There are a handfull of +options that shape the conversion. There is a utility function, +C<text2html>, that's exported by default. This function is simply a short- +cut to the Object Oriented interface described in detail below. + +=head2 Methods + +The following methods may be used as the public interface. + +=head3 new + + my $t2h = HTML::FromText->new({ + paras => 1, + blockcode => 1, + tables => 1, + bullets => 1, + numbers => 1, + urls => 1, + email => 1, + bold => 1, + underline => 1, + }); + +Constructs a new C<HTML::FromText> object using the given +configuration. The resulting object can parse lots of objects using the +C<parse> method. + +Options to C<new> are passed by name, with the value being either true +or false. If true, the option will be turned on. If false, it will be +turned off. The following outlines all the options. + +=head4 Decorators + +=over 5 + +=item metachars + +This option is on by default. + +All characters that are unsafe for HTML display will be encoded using +C<HTML::Entities::encode_entities()>. + +=item urls + +This option is off by default. + +Replaces URLs with links. + +=item email + +This option is off by default. + +Replaces email addresses with C<mailto:> links. + +=item bold + +This option is off by default. + +Replaces text surrounded by asterisks (C<*>) with the same text +surrounded by C<strong> tags. + +=item underline + +This option is off by default. + +Replaces text surrownded by underscores (C<_>) with the same text +surrounded by C<span> tags with an underline style. + +=back + +=head4 Output Modes + +The following are three output modes and the options associated with +them. They are listed in order of precidence. If none of these modes are +supplied, the basic decorators are applied to the text in whole. + +=over 5 + +=item B<pre> + +This option is off by default. + +Wraps the entire text in C<pre> tags. + +=item B<lines> + +This option is off by default. + +Preserves line breaks by inserting C<br> tags at the end of each line. + +This mode has further options. + +=over 5 + +=item spaces + +This option is off by default. + +All spaces are HTML encoded. + +=back + +=item B<paras> + +This option is off by default. + +Preserves paragraphs by wrapping them in C<p> tags. + +This mode has further options. + +=over 5 + +=item bullets + +This option is off by default. + +Convert bulleted lists into unordered lists (C<ul>). Bullets can be +either an asterisk (C<*>) or a hyphen (C<->). Lists can be nested. + +=item numbers + +This option is off by default. + +Convert numbered lists into ordered lists (C<ol>). Numbered lists are +identified by numerals. Lists may be nested. + +=item headings + +This option is off by default. + +Convert paragraphs identified as headings into HTML headings at +the appropriate level. The heading C<1. Top> would be heading +level one (C<h1>). The heading C<2.5.1. Blah> would be heading +level three (C<h3>). + +=item title + +This option is off by default. + +Convert the first paragraph to a heading level one (C<h1>). + +=item tables + +This option is off by default. + +Convert paragraphs identified as tables to HTML tables. Tables are two +or more rows and two or more columns. Columns should be separated by two +or more spaces. + +=back + +The following options apply specifically to indented paragraphs. They +are listed in order of precidence. + +=over 5 + +=item blockparas + +This option is off by default. + +Convert indented paragraphs to block quotes using the C<blockquote> tag. + +=item blockquotes + +Convert indented paragraphs as C<blockparas> would, but also preserving +line breaks. + +=item blockcode + +Convert indented paragraphs as C<blockquotes> would, but also preserving +spaces using C<pre> tags. + +=back + +=back + +=cut + +sub new { + my ($class, $options) = @_; + $options ||= {}; + $class->_croak("Options must be a hash reference") + if ref($options) ne 'HASH'; + + my %options = ( + metachars => 1, + urls => 0, + email => 0, + bold => 0, + underline => 0, + + pre => 0, + + lines => 0, + spaces => 0, + + paras => 0, + bullets => 0, + numbers => 0, + headings => 0, + title => 0, + blockparas => 0, + blockquotes => 0, + blockcode => 0, + tables => 0, + + %{ $options }, + ); + + my %self = ( + options => \%options, + text => '', + html => '', + ); + + return bless \%self, blessed($class) || $class; +} + +=head3 parse + + my $html = $t2h->parse( $text ); + +Parses text supplied as a single scalar string and returns the HTML as a +single scalar string. All the tabs in your text will be expanded using +C<Text::Tabs::expand()>. + +=cut + +sub parse { + my ($self, $text) = @_; + + $text = join "\n", expand( split /\n/, $text ); + + $self->{text} = $text; + $self->{html} = $text; + $self->{paras} = undef; + + my $options = $self->{options}; + + $self->metachars if $options->{metachars}; + + if ( $options->{pre} ) { $self->pre } + elsif ( $options->{lines} ) { $self->lines } + elsif ( $options->{paras} ) { $self->paras } + + $options->{$_} and $self->$_ foreach @DECORATORS; + + return $self->{html}; +} + +=head2 Functions + +=head3 text2html + + my $html = text2html( + $text, + urls => 1, + email => 1, + ); + +Functional interface that just wraps the OO interface. This function is +exported by default. If you don't want it you can C<require> the module +or C<use> it with an empty list. + + require HTML::FromText; + # or ... + use HTML::FromText (); + +=cut + +sub text2html { + my ($text, %options) = @_; + HTML::FromText->new(\%options)->parse($text); +} + +=head2 Subclassing + +B<Note:> At the time of this release, the internals of C<HTML::FromText> +are in a state of development and cannot be expected to stay the same +from release to release. I expect that release version B<3.00> will be +analogous to a C<1.00> release of other software. This is because the +current maintainer has rewritten this distribution from the ground up +for the C<2.x> series. You have been warned. + +The following methods may be used for subclassing C<HTML::FromText> +to create your own text to HTML conversions. Each of these methods +is passed just one argument, the object (C<$self>), unless +otherwise stated. + +The structure of C<$self> is as follows for this release. + + { + options => { + option_name => $value, + ... + }, + text => $text, # as passed to parse(), with tabs expanded + html => $html, # the HTML that will be returned from parse() + } + +=head3 pre + +Used when C<pre> mode is specified. + +Should set C<< $self->{html} >>. + +Return value is ignored. + +=cut + +sub pre { + my ($self) = @_; + $self->{html} = join $self->{html}, '<pre class="hft-pre">', '</pre>'; +} + +=head3 lines + +Used when C<lines> mode is specified. + +Implements the C<spaces> option internally when the option is set to a +true value. + +Should set C<< $self->{html} >>. + +Return value is ignored. + +=cut + +sub lines { + my ($self) = @_; + $self->{html} =~ s[ ][ ]g if $self->{options}->{spaces}; + $self->{html} =~ s[$][<br />]gm; + $self->{html} =~ s[^][<div class="hft-lines">]; + $self->{html} =~ s[$][</div>]; +} + +=head3 paras + +Used when the C<paras> mode is specified. + +Splits C<< $self->{text} >> into paragraphs internally and sets up +C<< $self->{paras} >> as follows. + + paras => { + 0 => { + text => $text, # paragraph text + html => $html, # paragraph html + }, + ... # and so on for all paragraphs + }, + +Implements the C<title> option internally when the option is turned on. + +Converts any normal paragraphs to HTML paragraphs (surrounded by C<p> +tags) internally. + +Should set C<< $self->{html} >>. + +Return value is ignored. + +=cut + +sub paras { + my ($self) = @_; + + my $options = $self->{options}; + my @paras = split /\n{2,}/, $self->{html}; + my %paras = map { $_, { text => $paras[$_], html => undef } } 0 .. $#paras; + $self->{paras} = \%paras; + + $self->{paras}->{0}->{html} = join( + $self->{paras}->{0}->{text}, + q[<h1 class="hft-title">], "</h1>\n" + ) if $options->{title}; + + $self->headings if $options->{headings}; + $self->bullets if $options->{bullets}; + $self->numbers if $options->{numbers}; + + $self->tables if $options->{tables}; + + if ( $options->{blockparas} ) { $self->blockparas } + elsif ( $options->{blockquotes} ) { $self->blockquotes } + elsif ( $options->{blockcode} ) { $self->blockcode } + + $self->_manipulate_paras(sub { qq[<p class="hft-paras">$_[0]</p>\n] }); + + $self->{html} = join "\n", map $paras{$_}->{html}, + sort { $a <=> $b } keys %paras; +} + +=head3 headings + +Used to format headings when the C<headings> option is turned on. + +Return value is ignored. + +=cut + +sub headings { + my ($self) = @_; + my $heading = qr/\d+\./; + + $self->_manipulate_paras(sub{ + my ($text) = @_; + return unless $text =~ m[^((?:$heading)+)\s+]; + + my $depth; $depth++ for split /\./, $1; + + qq[<h$depth class="hft-headings">$text</h$depth>\n]; + }); +} + +=head3 bullets + +Format bulleted lists when the C<bullets> option is turned on. + +Return value is ignored. + +=cut + +sub bullets { + my ($self) = @_; + $self->_format_list( qr/[*]/, 'ul', 'hft-bullets' ); + $self->_format_list( qr/[-]/, 'ul', 'hft-bullets' ); +} + +=head3 numbers + +Format numbered lists when the C<numbers> option is turned on. + +Return value is ignored. + +=cut + +sub numbers { + my ($self) = @_; + $self->_format_list( qr/[0-9]/, 'ol', 'hft-numbers'); +} + +=head3 tables + +Format tables when the C<tables> option is turned on. + +Return value is ignored. + +=cut + +sub tables { + my ($self) = @_; + + $self->_manipulate_paras(sub{ + my ($text) = $self->_remove_indent( $_[0] ); + + my @lines = split /\n/, $text; + my $columns = $self->_table_find_columns( + $self->_table_initial_spaces( split //, $lines[0] ), + [ @lines[1 .. $#lines] ], + ); + + return unless $columns; + $self->_table_create( $columns, \@lines ); + }); +} + +=head3 blockparas + +Used when the C<blockparas> option is turned on. + +Return value is ignored. + +=cut + +sub blockparas { + my ($self) = @_; + my $paras = $self->{paras}; + + $self->_manipulate_paras(sub{ + my ($text) = $self->_remove_indent( $_[0], 1 ); + my ($pnum, $paras) = @_[1,2]; + return unless $text; + + $self->_consolidate_blocks( + ( exists $paras->{$pnum - 1} ? $paras->{$pnum -1} : undef ), + 'blockparas', 1, + qq[<blockquote class="hft-blockparas"><p>$text</p></blockquote>\n], + ); + }); +} + +=head3 blockquotes + +Used when the C<blockquotes> option is turned on. + +Return value is ignored. + +=cut + +sub blockquotes { + my ($self) = @_; + my $paras = $self->{paras}; + + $self->_manipulate_paras(sub { + my ($text) = $self->_remove_indent( $_[0], 1 ); + return unless $text; + + $text =~ s[\n|$][<br />\n]g; + + qq[<blockquote class="hft-blockquotes"><div>$text</div></blockquote>\n]; + }); +} + +=head3 blockcode + +Used when the C<blockcode> option is turned on. + +Return value is ignored. + +=cut + +sub blockcode { + my ($self) = @_; + my $paras = $self->{paras}; + + $self->_manipulate_paras(sub { + my ($text) = $self->_remove_indent( $_[0], 1 ); + my ($pnum, $paras) = @_[1,2]; + return unless $text; + + $text =~ s[^][<pre>]; + $text =~ s[$][</pre>]; + $self->_consolidate_blocks( + ( exists $paras->{$pnum - 1} ? $paras->{$pnum -1} : undef ), + 'blockcode', 0, + qq[<blockquote class="hft-blockcode">$text</blockquote>\n], + ); + }); +} + +=head3 urls + +Turn urls into links when C<urls> option is turned on. + +Should operate on C<< $self->{html} >>. + +Return value is ignored. + +=cut + +sub urls { + my ($self) = @_; + $self->{html} =~ s[\b((?:$PROTOCOLS):[^\s<]+[\w/])] + [<a href="$1" class="hft-urls">$1</a>]og; +} + +=head3 email + +Turn email addresses into C<mailto:> links when C<email> option is +turned on. + +Should operate on C<< $self->{html} >>. + +Return value is ignored. + +=cut + +sub email { + my ($self) = @_; + $self->{html} =~ s[($Addr_spec_re)] + [<a href="mailto:$1" class="hft-email">$1</a>]og; +} + +=head3 underline + +Underline things between _underscores_ when C<underline> option is +turned on. + +Should operate on C<< $self->{html} >>. + +Return value is ignored. + +=cut + +sub underline { + my ($self) = @_; + $self->{html} =~ s[(?:^|(?<=\W))((_)([^\\_\n]*(?:\\.[^\\_\n]*)*)(_))(?:(?=\W)|$)] + [<span class="hft-underline" style="text-decoration: underline">$3</span>]g; +} + +=head3 bold + +Bold things between *asterisks* when C<bold> option is turned on. + +Should operate on C<< $self->{html} >>. + +Return value is ignored. + +=cut + +sub bold { + my ($self) = @_; + $self->{html} =~ s[(?:^|(?<=\W))((\*)([^\\\*\n]*(?:\\.[^\\\*\n]*)*)(\*))(?:(?=\W)|$)] + [<strong class="hft-bold">$3</strong>]g; +} + +=head3 metachars + +Encode meta characters when C<metachars> option is turned on. + +Should operate on C<< $self->{html} >>. + +Return value is ignored. + +=cut + +sub metachars { + my ($self) = @_; + $self->{html} = encode_entities( $self->{html} ); +} + +# private + +sub _croak { + my ($class, @error) = @_; + require Carp; + Carp::croak(@error); +} + +sub _carp { + my ($class, @error) = @_; + require Carp; + Carp::carp(@error); +} + +sub _format_list { + my ($self, $identifier, $parent, $class) = @_; + + $self->_manipulate_paras(sub { + my ($text) = @_; + return unless $text =~ m[^\s*($identifier)\s+]; + + my ($pos, $html, @open) = (-1, ''); + foreach my $line ( split /\n(?=\s*$identifier)/, $text ) { + $line =~ s[(\s*)$identifier][]; + my $line_pos = length $1; + if ($line_pos > $pos) { + $html .= (' ' x $line_pos) . qq[<$parent class="$class">\n]; + push @open, $line_pos; + } elsif ($line_pos < $pos) { + until ( $open[-1] <= $line_pos ) { + $html .= (' ' x pop @open) . "</$parent>\n"; + } + } + $html .= (' ' x ($pos = $line_pos)) . "<li>$line</li>\n"; + } + $html .= "</$parent>\n"x@open; + }); +} + +sub _manipulate_paras { + my ($self, $action) = @_; + + my $paras = $self->{paras}; + + foreach my $pnum ( sort { $a <=> $b } keys %{$paras}) { + my $para = $paras->{$pnum}; + $para->{html} = $action->($para->{text}, $pnum, $paras) + unless $para->{html}; + } +} + +sub _table_initial_spaces { + my ($self, @chars) = @_; + + my %spaces; + foreach ( 0 .. $#chars ) { + my ($open_space) = grep { !defined( $_->{end} ) } values %spaces; + if ( $chars[$_] eq ' ' ) { + $spaces{$_} = {start => $_, end => undef} unless $open_space; + } else { + if ( $open_space && $_ - $open_space->{start} > 1 ) { + $open_space->{end} = $_ - 1; + } else { + delete $spaces{$open_space->{start}} if $open_space; + } + } + } + return \%spaces; +} + +sub _table_find_columns { + my ($self, $spaces, $lines) = @_; + return unless keys %{$spaces}; + my %spots; + foreach my $line ( @{$lines} ) { + foreach my $pos ( sort { $a <=> $b } keys %{$spaces} ) { + my $key; + $key = $spaces->{$pos}->{start} + if substr( $line, $spaces->{$pos}->{start}, 1 ) eq ' '; + $key = $spaces->{$pos}->{end} + if substr( $line, $spaces->{$pos}->{end}, 1 ) eq ' ' && ! $key; + if ( $key ) { + $spots{$key}++; + $spots{$spaces->{$pos}->{start}}++ + if $spots{$spaces->{$pos}->{start}} && $key ne $spaces->{$pos}->{start}; + $spots{$spaces->{$pos}->{end}}++ + if $key ne $spaces->{$pos}->{end}; + } else { + delete $spaces->{$pos}; + } + } + foreach my $spot (sort {$b <=> $a} keys %spots) { + if ( substr( $line, $spot, 1 ) ne ' ' ) { + delete $spots{$spot}; + } + if ( exists $spaces->{$spot}) { + my $space = $spaces->{$spot}; + if ( exists $spots{$space->{start}} && $spots{$space->{end}}) { + delete $spots{$spot}; + } + } + } + } + + + my @spots = grep { $spots{$_} == @{$lines} } sort { $a <=> $b } keys %spots; + return @spots ? join( '', ( + map { + my $ret = 'A' . ( $spots[$_] - ( $_ == 0 ? 0 : $spots[$_ - 1] ) ); + $ret eq 'A0' ? () : $ret; + } 0 .. $#spots + ), 'A*' ) : undef; +} + +sub _table_create { + my ($self, $columns, $lines) = @_; + + my $table = qq[<table class="hft-tables">\n]; + foreach my $line ( @{$lines} ) { + $table .= join( '', + ' <tr><td>', + join( + '</td><td>', + map { s/^\s+//; s/\s$//; $_ } unpack $columns, $line + ), + "</td></tr>\n", + ); + } + $table .= "</table>\n"; +} + +sub _remove_indent { + my ($self, $text, $strict) = @_; + return if $text !~ m[^(\s+).+(?:\n\1.+)*$] && $strict; + $text =~ s[^$1][]mg if $1; + return $text; +} + +sub _consolidate_blocks { + my ($self, $prev_para, $class, $keep_inner, $html) = @_; + if ( $prev_para && $prev_para->{html} =~ m[<blockquote class="hft-$class"><(\w+)>] ) { + my $inner_tag = $keep_inner ? '' : qr[</?$1>]; + $prev_para->{html} =~ s[$inner_tag</blockquote>][]; + $html =~ s[<blockquote class="hft-$class">$inner_tag][]; + } + return $html; +} + +1; + +__END__ + +=head2 Output + +The output from C<HTML::FromText> has been updated to pass XHTML 1.1 +validation. Every HTML tag that should have a CSS class name does. They +are prefixed with C<hft-> and correspond to the names of the options to +C<new()> (or C<text2html()>). For example C<hft-lines>, C<hft-paras>, +and C<hft-urls>. + +One important note is the output for C<underline>. Because the <u> tag +is deprecated in this specification a C<span> is used with a style +attribute of C<text-decoration: underline>. The class is C<hft- +underline>. If you want to override the C<text-decoration> style in the +CSS class you'll need to do so like this. + + text-decoration: none !important; + +=head1 SEE ALSO + +L<text2html(1)>. + +=head1 AUTHOR + +Casey West <F<casey@geeknest.com>>. + +=head1 AUTHOR EMERITUS + +Gareth Rees <F<garethr@cre.canon.co.uk>>. + +=head1 COPYRIGHT + + Copyright (c) 2003 Casey West. All rights reserved. + This module is free software; you can redistribute it and/or modify it + under the same terms as Perl itself. + +=cut diff --git a/cpan/dist/HTML-FromText/t/01_features.t b/cpan/dist/HTML-FromText/t/01_features.t new file mode 100644 index 00000000..f4cce2bd --- /dev/null +++ b/cpan/dist/HTML-FromText/t/01_features.t @@ -0,0 +1,296 @@ +BEGIN { + use Test::More qw[no_plan]; + use_ok 'HTML::FromText'; +} + +use strict; +use warnings; + +my $t2h = HTML::FromText->new; +isa_ok( $t2h, 'HTML::FromText', 'default' ); +my $html = $t2h->parse( '<>' ); +cmp_ok( $html, 'eq', '<>', 'metachars encoded <> correctly' ); + + +$t2h = HTML::FromText->new({underline => 1}); +$html = $t2h->parse( '_underline_' ); +cmp_ok( $html, 'eq', '<span class="hft-underline" style="text-decoration: underline">underline</span>', 'underline did' ); + +$t2h = HTML::FromText->new({underline => 1}); +$html = $t2h->parse( "_should\nnot_" ); +cmp_ok( $html, 'eq', "_should\nnot_", 'underline should not across lines' ); + + +$t2h = HTML::FromText->new({bold => 1}); +$html = $t2h->parse( '*bold*' ); +cmp_ok( $html, 'eq', '<strong class="hft-bold">bold</strong>', 'bold did' ); + + +$t2h = HTML::FromText->new({urls => 1}); +$html = $t2h->parse( 'http://example.com' ); +cmp_ok( $html, 'eq', '<a href="http://example.com" class="hft-urls">http://example.com</a>', 'urls did' ); + + +$t2h = HTML::FromText->new({urls => 1}); +$html = $t2h->parse( 'http://example.com/?foo=bar&baz=quux' ); +cmp_ok( $html, 'eq', '<a href="http://example.com/?foo=bar&baz=quux" class="hft-urls">http://example.com/?foo=bar&baz=quux</a>', 'urls and metachars did' ); + + +$t2h = HTML::FromText->new({email => 1}); +$html = $t2h->parse( 'casey@geeknest.com' ); +cmp_ok( $html, 'eq', '<a href="mailto:casey@geeknest.com" class="hft-email">casey@geeknest.com</a>', 'email did' ); + + +$t2h = HTML::FromText->new({pre => 1}); +$html = $t2h->parse( 'pre' ); +cmp_ok( $html, 'eq', '<pre class="hft-pre">pre</pre>', 'pre did' ); + + +$t2h = HTML::FromText->new({lines => 1}); +$html = $t2h->parse( "one\ntwo" ); +cmp_ok( $html, 'eq', qq[<div class="hft-lines">one<br />\ntwo<br /></div>], 'lines did' ); + + +$t2h = HTML::FromText->new({lines => 1,spaces => 1}); +$html = $t2h->parse( "one\n two" ); +cmp_ok( $html, 'eq', qq[<div class="hft-lines">one<br />\n two<br /></div>], 'lines and spaces did' ); + +$t2h = HTML::FromText->new({paras => 1}); +$html = $t2h->parse( <<__TEXT__ ); +One +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'one paragraph' ); +<p class="hft-paras">One</p> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1}); +$html = $t2h->parse( <<__TEXT__ ); +One + +Two +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'two paragraphs' ); +<p class="hft-paras">One</p> + +<p class="hft-paras">Two</p> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, bullets => 1}); +$html = $t2h->parse( <<__TEXT__ ); + * One + * Two +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'single bullet list' ); + <ul class="hft-bullets"> + <li> One</li> + <li> Two</li> +</ul> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, bullets => 1}); +$html = $t2h->parse( <<__TEXT__ ); +- One + - Half +- Two +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'nested bullet list' ); +<ul class="hft-bullets"> +<li> One</li> + <ul class="hft-bullets"> + <li> Half</li> + </ul> +<li> Two</li> +</ul> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, bullets => 1, bold => 1}); +$html = $t2h->parse( <<__TEXT__ ); +* One + * Half + * Whole + * Shabang + Dude +* Two + +*Normal* Text +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'nested bullets and normal paragraph' ); +<ul class="hft-bullets"> +<li> One</li> + <ul class="hft-bullets"> + <li> Half</li> + <li> Whole</li> + <ul class="hft-bullets"> + <li> Shabang + Dude</li> + </ul> + </ul> +<li> Two</li> +</ul> + +<p class="hft-paras"><strong class="hft-bold">Normal</strong> Text</p> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, numbers => 1}); +$html = $t2h->parse( <<__TEXT__ ); +1 One + 1 Half + 2 Whole + 1 Shabang + Dude +2 Two + +Normal Text +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'nested numbers and normal paragraph' ); +<ol class="hft-numbers"> +<li> One</li> + <ol class="hft-numbers"> + <li> Half</li> + <li> Whole</li> + <ol class="hft-numbers"> + <li> Shabang + Dude</li> + </ol> + </ol> +<li> Two</li> +</ol> + +<p class="hft-paras">Normal Text</p> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, headings => 1}); +$html = $t2h->parse( <<__TEXT__ ); +1. One + +Normal Text + +1.1. Sub section + +2. Second Top + +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'headings' ); +<h1 class="hft-headings">1. One</h1> + +<p class="hft-paras">Normal Text</p> + +<h2 class="hft-headings">1.1. Sub section</h2> + +<h1 class="hft-headings">2. Second Top</h1> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, title => 1}); +$html = $t2h->parse( <<__TEXT__ ); +Title + +Normal Text +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'title' ); +<h1 class="hft-title">Title</h1> + +<p class="hft-paras">Normal Text</p> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, blockparas => 1}); +$html = $t2h->parse( <<__TEXT__ ); + Test +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'blockparas' ); +<blockquote class="hft-blockparas"><p>Test</p></blockquote> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, blockquotes => 1}); +$html = $t2h->parse( <<__TEXT__ ); + Test + This +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'blockquotes' ); +<blockquote class="hft-blockquotes"><div>Test<br /> +This<br /> +</div></blockquote> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, blockcode => 1}); +$html = $t2h->parse( <<__TEXT__ ); + Test + This Please + +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'blockcode' ); +<blockquote class="hft-blockcode"><pre>Test +This Please</pre></blockquote> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, tables => 1}); +$html = $t2h->parse( <<__TEXT__ ); +Casey West Daddy +Chastity West Mommy +Evelina West Baby +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'tables' ); +<table class="hft-tables"> + <tr><td>Casey West</td><td>Daddy</td></tr> + <tr><td>Chastity West</td><td>Mommy</td></tr> + <tr><td>Evelina West</td><td>Baby</td></tr> +</table> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, tables => 1}); +$html = $t2h->parse( <<__TEXT__ ); + Chastity West Mommy + Casey West Daddy +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'indented tables' ); +<table class="hft-tables"> + <tr><td>Chastity West</td><td>Mommy</td></tr> + <tr><td>Casey West</td><td>Daddy</td></tr> +</table> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, tables => 1}); +$html = $t2h->parse( <<__TEXT__ ); + Chastity West Mommy + Casey West Daddy +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'should not be table' ); +<p class="hft-paras"> Chastity West Mommy + Casey West Daddy</p> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, tables => 1}); +$html = $t2h->parse( <<__TEXT__ ); + Casey West Daddy Tall + Chastity West Mommy Short + +Normal Text. +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'indented tables with normal para' ); +<table class="hft-tables"> + <tr><td>Casey West</td><td>Daddy</td><td>Tall</td></tr> + <tr><td>Chastity West</td><td>Mommy</td><td>Short</td></tr> +</table> + +<p class="hft-paras">Normal Text.</p> +__HTML__ + +$t2h = HTML::FromText->new({paras => 1, tables => 1}); +$html = $t2h->parse( <<__TEXT__ ); +http://www.pm.org Perl Mongers +http://perl.com O'Reilly Perl Center +http://lists.perl.org List of Mailing Lists +http://use.perl.org Perl News and Community Journals +http://perl.apache.org mod_perl +http://theperlreview.com The Perl Review +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'indented tables with normal para' ); +<table class="hft-tables"> + <tr><td>http://www.pm.org</td><td>Perl Mongers</td></tr> + <tr><td>http://perl.com</td><td>O'Reilly Perl Center</td></tr> + <tr><td>http://lists.perl.org</td><td>List of Mailing Lists</td></tr> + <tr><td>http://use.perl.org</td><td>Perl News and Community Journals</td></tr> + <tr><td>http://perl.apache.org</td><td>mod_perl</td></tr> + <tr><td>http://theperlreview.com</td><td>The Perl Review</td></tr> +</table> +__HTML__ + diff --git a/cpan/dist/HTML-FromText/t/02_v2.01.t b/cpan/dist/HTML-FromText/t/02_v2.01.t new file mode 100644 index 00000000..10e843a1 --- /dev/null +++ b/cpan/dist/HTML-FromText/t/02_v2.01.t @@ -0,0 +1,109 @@ +use Test::More qw[no_plan]; + +use_ok( 'HTML::FromText' ); + +my $html = text2html( <<__TEXT__, paras => 1, bullets => 1, bold => 1 ); +* An article on *how* to do test... +--- + +*With C/C++* +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'mixing bullets should not work' ); +<ul class="hft-bullets"> +<li> An article on <strong class="hft-bold">how</strong> to do test... +---</li> +</ul> + +<p class="hft-paras"><strong class="hft-bold">With C/C++</strong></p> +__HTML__ + +$html = text2html( <<__TEXT__, paras => 1, urls => 1 ); +http://example.com/i-ndex.html#test +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'url with hash' ); +<p class="hft-paras"><a href="http://example.com/i-ndex.html#test" class="hft-urls">http://example.com/i-ndex.html#test</a></p> +__HTML__ + +$html = text2html( <<__TEXT__, paras => 1, underline => 1 ); +mod_perl/mod_ssl + +_foo_ + +_foo_. +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'complex underlines' ); +<p class="hft-paras">mod_perl/mod_ssl</p> + +<p class="hft-paras"><span class="hft-underline" style="text-decoration: underline">foo</span></p> + +<p class="hft-paras"><span class="hft-underline" style="text-decoration: underline">foo</span>.</p> +__HTML__ + +$html = text2html( <<__TEXT__, paras => 1, bold => 1 ); +foo*foo*foo + +*foo* + +*foo*. +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'complex bolds' ); +<p class="hft-paras">foo*foo*foo</p> + +<p class="hft-paras"><strong class="hft-bold">foo</strong></p> + +<p class="hft-paras"><strong class="hft-bold">foo</strong>.</p> +__HTML__ + + +$html = text2html( <<__TEXT__, paras => 1, bullets => 1 ); +* Fast, powerful and extensible template processing system. + * Powerful presentation language supports all standard templating directives, e.g. variable substitution, includes, conditionals, + loops. + * Many additional features such as output filtering, exception handling, macro definition, support for plugin objects, definition + of template metadata, embedded Perl code (only enabled by EVAL_PERL option), definition of template blocks, a 'switch' + statement, and more. + * Full support for complex Perl data types such as hashes, lists, objects and sub-routine references. + * Clear separation of concerns between user interface (templates), application code (Perl objects/sub-routines) and data + (Perl data). + * Programmer-centric back end, allowing application logic and data structures to be built in Perl. + * Designer-centric front end, hiding underlying complexity behind simple variable access. + * Templates are compiled to Perl code for maximum runtime efficiency and performance. Compiled templates are cached + and can be written to disk in "compiled form" (e.g. Perl code) to achieve cache persistance. + * Well suited to online dynamic web content generation (e.g. Apache/mod_perl). + * Also has excellent support for offline batch processing for generating static pages (e.g. HTML, POD, LaTeX, PostScript, + plain text) from source templates. + * Comprehensive documentation including tutorial and reference manuals. + * Fully Open Source and Free +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'complex bullets' ); +<ul class="hft-bullets"> +<li> Fast, powerful and extensible template processing system. </li> + <ul class="hft-bullets"> + <li> Powerful presentation language supports all standard templating directives, e.g. variable substitution, includes, conditionals, + loops. </li> + <ul class="hft-bullets"> + <li> Many additional features such as output filtering, exception handling, macro definition, support for plugin objects, definition + of template metadata, embedded Perl code (only enabled by EVAL_PERL option), definition of template blocks, a 'switch' + statement, and more. </li> + <li> Full support for complex Perl data types such as hashes, lists, objects and sub-routine references. </li> + </ul> + <li> Clear separation of concerns between user interface (templates), application code (Perl objects/sub-routines) and data + (Perl data). </li> + <ul class="hft-bullets"> + <li> Programmer-centric back end, allowing application logic and data structures to be built in Perl. </li> + <li> Designer-centric front end, hiding underlying complexity behind simple variable access. </li> + <li> Templates are compiled to Perl code for maximum runtime efficiency and performance. Compiled templates are cached + and can be written to disk in "compiled form" (e.g. Perl code) to achieve cache persistance. </li> + <ul class="hft-bullets"> + <li> Well suited to online dynamic web content generation (e.g. Apache/mod_perl). </li> + <li> Also has excellent support for offline batch processing for generating static pages (e.g. HTML, POD, LaTeX, PostScript, + plain text) from source templates. </li> + <ul class="hft-bullets"> + <li> Comprehensive documentation including tutorial and reference manuals. </li> + <li> Fully Open Source and Free </li> +</ul> +</ul> +</ul> +</ul> +</ul> +__HTML__ diff --git a/cpan/dist/HTML-FromText/t/03_v2.02.t b/cpan/dist/HTML-FromText/t/03_v2.02.t new file mode 100644 index 00000000..8eec81af --- /dev/null +++ b/cpan/dist/HTML-FromText/t/03_v2.02.t @@ -0,0 +1,29 @@ +use Test::More; + +my $script = 'blib/script/text2html'; + +plan skip_all => "$script doesn't exist" + unless -e $script; + +plan 'no_plan'; + +open T2H, "perl -Iblib/lib $script --paras t/files/paras.txt |" or die $!; +undef $/; +my $html = <T2H>; +close T2H; + +cmp_ok( $html, 'eq', <<__HTML__, 'output from text2html correct' ); +<p class="hft-paras">Hello</p> + +<p class="hft-paras">Test</p> +__HTML__ + +use_ok 'HTML::FromText'; + +$html = text2html( <<__TEXT__, paras => 1, blockcode => 1 ); + Foo Bar +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'blockcode should preserve spaces' ); +<blockquote class="hft-blockcode"><pre>Foo Bar</pre></blockquote> +__HTML__ + diff --git a/cpan/dist/HTML-FromText/t/04_v2.03.t b/cpan/dist/HTML-FromText/t/04_v2.03.t new file mode 100644 index 00000000..1c4691f6 --- /dev/null +++ b/cpan/dist/HTML-FromText/t/04_v2.03.t @@ -0,0 +1,68 @@ +use Test::More 'no_plan'; + +use_ok 'HTML::FromText'; + +$html = text2html( <<__TEXT__, paras => 1, blockcode => 1 ); + Foo Bar +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'blockcode should use pre' ); +<blockquote class="hft-blockcode"><pre>Foo Bar</pre></blockquote> +__HTML__ + +$html = text2html( <<__TEXT__, paras => 1, blockparas => 1 ); + Foo Bar +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'blockparas should use p' ); +<blockquote class="hft-blockparas"><p>Foo Bar</p></blockquote> +__HTML__ + +$html = text2html( <<__TEXT__, paras => 1, blockquotes => 1 ); + Foo Bar +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'blockquotes should use div' ); +<blockquote class="hft-blockquotes"><div>Foo Bar<br /> +</div></blockquote> +__HTML__ + +$html = text2html( <<__TEXT__, paras => 1, tables => 1 ); +Perl Command Line Casey West +Introduction to CPAN Testing Adam J. Foxson +Parsing JavaScript David Hand +Test Better with Test::More Casey West +Creating a Template Toolkit Plugin Chris Winters +GD::SIRDS David Hand +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'table should work' ); +<table class="hft-tables"> + <tr><td>Perl Command Line</td><td>Casey West</td></tr> + <tr><td>Introduction to CPAN Testing</td><td>Adam J. Foxson</td></tr> + <tr><td>Parsing JavaScript</td><td>David Hand</td></tr> + <tr><td>Test Better with Test::More</td><td>Casey West</td></tr> + <tr><td>Creating a Template Toolkit Plugin</td><td>Chris Winters</td></tr> + <tr><td>GD::SIRDS</td><td>David Hand</td></tr> +</table> +__HTML__ + +$html = text2html( <<__TEXT__, paras => 1, tables => 1 ); +*01.08.2003* 19:00 Robot Club http://pgh.pm.org/m/200301.html +*02.12.2003* 19:00 Lightning Talks http://pgh.pm.org/m/200302.html +*03.12.2003* 19:00 Social Gathering http://pgh.pm.org/m/200303.html +*04.09.2003* 19:00 Technical Meeting http://pgh.pm.org/m/200304.html +*05.14.2003* 19:00 Social Gathering http://pgh.pm.org/m/200305.html +*06.14.2003* 11:00 /burgh?/ Meetup http://pgh.pm.org/m/200306.html +*07.09.2003* 19:00 Social Meeting http://pgh.pm.org/m/200307.html +*08.13.2003* 19:00 Technical Meeting http://pgh.pm.org/m/200308.html +__TEXT__ +cmp_ok( $html, 'eq', <<__HTML__, 'table should work' ); +<table class="hft-tables"> + <tr><td>*01.08.2003*</td><td>19:00</td><td>Robot Club</td><td>http://pgh.pm.org/m/200301.html</td></tr> + <tr><td>*02.12.2003*</td><td>19:00</td><td>Lightning Talks</td><td>http://pgh.pm.org/m/200302.html</td></tr> + <tr><td>*03.12.2003*</td><td>19:00</td><td>Social Gathering</td><td>http://pgh.pm.org/m/200303.html</td></tr> + <tr><td>*04.09.2003*</td><td>19:00</td><td>Technical Meeting</td><td>http://pgh.pm.org/m/200304.html</td></tr> + <tr><td>*05.14.2003*</td><td>19:00</td><td>Social Gathering</td><td>http://pgh.pm.org/m/200305.html</td></tr> + <tr><td>*06.14.2003*</td><td>11:00</td><td>/burgh?/ Meetup</td><td>http://pgh.pm.org/m/200306.html</td></tr> + <tr><td>*07.09.2003*</td><td>19:00</td><td>Social Meeting</td><td>http://pgh.pm.org/m/200307.html</td></tr> + <tr><td>*08.13.2003*</td><td>19:00</td><td>Technical Meeting</td><td>http://pgh.pm.org/m/200308.html</td></tr> +</table> +__HTML__ + diff --git a/cpan/dist/HTML-FromText/t/05_v2.04.t b/cpan/dist/HTML-FromText/t/05_v2.04.t new file mode 100644 index 00000000..88cd4653 --- /dev/null +++ b/cpan/dist/HTML-FromText/t/05_v2.04.t @@ -0,0 +1,3 @@ +use Test::More tests => 1; + +use_ok 'HTML::FromText'; diff --git a/cpan/dist/HTML-FromText/t/06_v2.05.t b/cpan/dist/HTML-FromText/t/06_v2.05.t new file mode 100644 index 00000000..fc09773f --- /dev/null +++ b/cpan/dist/HTML-FromText/t/06_v2.05.t @@ -0,0 +1,25 @@ +use Test::More qw[no_plan]; + +use_ok 'HTML::FromText'; + +my $html = text2html( <<'__TEXT__', paras => 1, blockcode => 1 ); + my $who = "World"; + + print "Hello, $who!\n"; +__TEXT__ +cmp_ok( $html, 'eq', <<'__HTML__', 'blockcode consolidated' ); +<blockquote class="hft-blockcode"><pre>my $who = "World"; + +print "Hello, $who!\n";</pre></blockquote> +__HTML__ + +$html = text2html( <<'__TEXT__', paras => 1, blockparas => 1 ); + Hello + + World +__TEXT__ +cmp_ok( $html, 'eq', <<'__HTML__', 'blockparas consolidated' ); +<blockquote class="hft-blockparas"><p>Hello</p> + +<p>World</p></blockquote> +__HTML__ diff --git a/cpan/dist/HTML-FromText/t/99_pod.t b/cpan/dist/HTML-FromText/t/99_pod.t new file mode 100644 index 00000000..51188dfa --- /dev/null +++ b/cpan/dist/HTML-FromText/t/99_pod.t @@ -0,0 +1,34 @@ +# -*- cperl -*- +#$Id$ + +=pod + +Testing that the POD in all the Perl code is formatted correctly. + +=cut + +use Test::More; +use File::Spec; +use File::Find; +use strict; + +eval "use Test::Pod 0.95"; + +if ($@) { + plan skip_all => "Test::Pod v0.95 required for testing POD"; +} else { + Test::Pod->import; + my @files; + my $blib = File::Spec->catfile(qw(blib lib)); + find( + sub { + push @files, $File::Find::name if /\.(?:p(?:l|m|od)|t)$/; + }, + $blib, + ( -e 't' && -d _ ? 't' : () ) + ); + plan tests => scalar @files; + foreach my $file (@files) { + pod_file_ok($file); + } +} diff --git a/cpan/dist/HTML-FromText/t/files/paras.txt b/cpan/dist/HTML-FromText/t/files/paras.txt new file mode 100644 index 00000000..a6bd9535 --- /dev/null +++ b/cpan/dist/HTML-FromText/t/files/paras.txt @@ -0,0 +1,3 @@ +Hello + +Test |
