r66043 - in /branches/upstream/libhtml-formattext-withlinks-perl/current: Changes MANIFEST META.yml lib/HTML/FormatText/WithLinks.pm t/skip_linked_urls.t t/with_emphasis.t

ansgar at users.alioth.debian.org ansgar at users.alioth.debian.org
Mon Dec 20 17:37:39 UTC 2010


Author: ansgar
Date: Mon Dec 20 17:35:38 2010
New Revision: 66043

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=66043
Log:
[svn-upgrade] new version libhtml-formattext-withlinks-perl (0.14)

Added:
    branches/upstream/libhtml-formattext-withlinks-perl/current/t/skip_linked_urls.t
Modified:
    branches/upstream/libhtml-formattext-withlinks-perl/current/Changes
    branches/upstream/libhtml-formattext-withlinks-perl/current/MANIFEST
    branches/upstream/libhtml-formattext-withlinks-perl/current/META.yml
    branches/upstream/libhtml-formattext-withlinks-perl/current/lib/HTML/FormatText/WithLinks.pm
    branches/upstream/libhtml-formattext-withlinks-perl/current/t/with_emphasis.t

Modified: branches/upstream/libhtml-formattext-withlinks-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formattext-withlinks-perl/current/Changes?rev=66043&op=diff
==============================================================================
--- branches/upstream/libhtml-formattext-withlinks-perl/current/Changes (original)
+++ branches/upstream/libhtml-formattext-withlinks-perl/current/Changes Mon Dec 20 17:35:38 2010
@@ -1,4 +1,12 @@
 # Changelog for HTML::FormatText::WithLinks
+version:    0.14
+date:       9/12/2010
+    Missed the skipped links test from the MANIFEST :(
+---
+version:    0.13
+date:       9/12/2010
+    Added code to change the delimiters for italic and bold text <Thomas Sibley> (rt #63571)
+---
 version:    0.12
 date:       27/11/2010       
     Updated HTML::FormatText dependancy to require version 2+

Modified: branches/upstream/libhtml-formattext-withlinks-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formattext-withlinks-perl/current/MANIFEST?rev=66043&op=diff
==============================================================================
--- branches/upstream/libhtml-formattext-withlinks-perl/current/MANIFEST (original)
+++ branches/upstream/libhtml-formattext-withlinks-perl/current/MANIFEST Mon Dec 20 17:35:38 2010
@@ -26,5 +26,6 @@
 t/parse_with_relative_links.t
 t/pod.t
 t/podcover.t
+t/skip_linked_urls.t
 t/treebuilder_problem.t
 t/with_emphasis.t

Modified: branches/upstream/libhtml-formattext-withlinks-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formattext-withlinks-perl/current/META.yml?rev=66043&op=diff
==============================================================================
--- branches/upstream/libhtml-formattext-withlinks-perl/current/META.yml (original)
+++ branches/upstream/libhtml-formattext-withlinks-perl/current/META.yml Mon Dec 20 17:35:38 2010
@@ -4,7 +4,7 @@
   - 'Struan Donald. E<lt>struan at cpan.orgE<gt>'
   - "Ian Malpass E<lt>ian at indecorous.comE<gt> was responsible for the custom \nformatting bits and the nudge to release the code."
   - "Simon Dassow E<lt>janus at errornet.de<gt> for the anchor_links option plus \na few bugfixes and optimisations"
-  - 'Thomas Sibley E<lt>trs at bestpractical.comE<gt> for the skip linked urls code.'
+  - 'Thomas Sibley E<lt>trs at bestpractical.comE<gt> patches for skipping links that are their urls and to change the delimiters for bold and italic text..'
 build_requires:
   Test::More: 0
 configure_requires:
@@ -18,11 +18,11 @@
 provides:
   HTML::FormatText::WithLinks:
     file: lib/HTML/FormatText/WithLinks.pm
-    version: 0.12
+    version: 0.14
 requires:
   HTML::FormatText: 2
   HTML::TreeBuilder: 0
   URI::WithBase: 0
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.12
+version: 0.14

Modified: branches/upstream/libhtml-formattext-withlinks-perl/current/lib/HTML/FormatText/WithLinks.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formattext-withlinks-perl/current/lib/HTML/FormatText/WithLinks.pm?rev=66043&op=diff
==============================================================================
--- branches/upstream/libhtml-formattext-withlinks-perl/current/lib/HTML/FormatText/WithLinks.pm (original)
+++ branches/upstream/libhtml-formattext-withlinks-perl/current/lib/HTML/FormatText/WithLinks.pm Mon Dec 20 17:35:38 2010
@@ -6,7 +6,7 @@
 use base qw(HTML::FormatText);
 use vars qw($VERSION);
 
-$VERSION = '0.12';
+$VERSION = '0.14';
 
 sub new {
 
@@ -45,8 +45,12 @@
 
     $self->{_link_track} = {};
 
+    $self->{bold_marker}    = '_';
+    $self->{italic_marker}  = '/';
+
     foreach ( qw( before_link after_link footnote link_num_generator 
-                  with_emphasis unique_links anchor_links skip_linked_urls ) ) {
+                  with_emphasis bold_marker italic_marker
+                  unique_links anchor_links skip_linked_urls ) ) {
         $self->{ $_ } = $hash->{ $_ } if exists $hash->{ $_ };
         delete $hash->{ $_ };
     }
@@ -157,25 +161,25 @@
 
 sub b_start {
     my $self = shift;
-    $self->out( '_' ) if $self->{ with_emphasis };
+    $self->out( $self->{'bold_marker'} ) if $self->{ with_emphasis };
     $self->SUPER::b_start();
 }
 
 sub b_end {
     my $self = shift;
-    $self->out( '_' ) if $self->{ with_emphasis };
+    $self->out( $self->{'bold_marker'} ) if $self->{ with_emphasis };
     $self->SUPER::b_end();
 }
 
 sub i_start {
     my $self = shift;
-    $self->out( '/' ) if $self->{ with_emphasis };
+    $self->out( $self->{'italic_marker'} ) if $self->{ with_emphasis };
     $self->SUPER::i_start();
 }
 
 sub i_end {
     my $self = shift;
-    $self->out( '/' ) if $self->{ with_emphasis };
+    $self->out( $self->{'italic_marker'} ) if $self->{ with_emphasis };
     $self->SUPER::i_end();
 }
 
@@ -391,7 +395,9 @@
 
 =item with_emphasis
 
-If set to 1 then italicised text will be surrounded by / and bolded text by _.
+If set to 1 then italicised text will be surrounded by C</> and bolded text by
+C<_>.  You can change these markers by using the C<italic_marker> and
+C<bold_marker> options.
 
 =item unique_links
 
@@ -458,7 +464,7 @@
 
 Kevin Ryde for the code for pulling the base out the document.
 
-Thomas Sibley E<lt>trs at bestpractical.comE<gt> for the skip linked urls code.
+Thomas Sibley E<lt>trs at bestpractical.comE<gt> patches for skipping links that are their urls and to change the delimiters for bold and italic text..
 
 =head1 COPYRIGHT
 

Added: branches/upstream/libhtml-formattext-withlinks-perl/current/t/skip_linked_urls.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formattext-withlinks-perl/current/t/skip_linked_urls.t?rev=66043&op=file
==============================================================================
--- branches/upstream/libhtml-formattext-withlinks-perl/current/t/skip_linked_urls.t (added)
+++ branches/upstream/libhtml-formattext-withlinks-perl/current/t/skip_linked_urls.t Mon Dec 20 17:35:38 2010
@@ -1,0 +1,49 @@
+use Test::More 'no_plan';
+use HTML::FormatText::WithLinks;
+
+my $html = simple_example();
+my $f = HTML::FormatText::WithLinks->new(
+    leftmargin          => 0,
+    skip_linked_urls    => 1,
+    before_link         => '',
+    after_link          => ' (%l)',
+    footnote            => ''
+);
+
+ok($f, 'object created');
+
+my $text = $f->parse($html);
+
+my $correct_text = qq!This is a mail of some sort with a bunch of linked URLs.
+
+http://example.com/
+
+and another https://example.com/
+
+ftp now ftp://example.com
+
+not the same but not this (http://example.com/)
+
+or this http://example.com (http://example.com/foo)
+
+!;
+
+ok($text, 'html formatted');
+is($text, $correct_text, 'html correctly formatted');
+
+
+sub simple_example {
+return <<'HTML';
+<html>
+<body>
+<p>This is a mail of some sort with a bunch of linked URLs.</p>
+<p><a href="http://example.com/">http://example.com/</a></p>
+<p>and another <a href="https://example.com/">https://example.com/</a></p>
+<p>ftp now <a href="ftp://example.com">ftp://example.com</a></p>
+<p>not the same <a href="http://example.com/">but not this</a></p>
+<p>or this <a href="http://example.com/foo">http://example.com</a></p>
+</body>
+</html>
+HTML
+}
+

Modified: branches/upstream/libhtml-formattext-withlinks-perl/current/t/with_emphasis.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formattext-withlinks-perl/current/t/with_emphasis.t?rev=66043&op=diff
==============================================================================
--- branches/upstream/libhtml-formattext-withlinks-perl/current/t/with_emphasis.t (original)
+++ branches/upstream/libhtml-formattext-withlinks-perl/current/t/with_emphasis.t Mon Dec 20 17:35:38 2010
@@ -1,6 +1,6 @@
 # $Id: 02_basic_parse.t 383 2004-01-12 17:09:27Z struan $
 
-use Test::More tests => 6;
+use Test::More tests => 9;
 use HTML::FormatText::WithLinks;
 
 my $html = new_html();
@@ -22,6 +22,13 @@
 ok( $text2, "html formatted" );
 is( $text2, "   This is a mail of some sort\n\n   It has some of the words emphasised\n\n", 'html correctly formatted without emphasis' ); 
 
+# Test alternate markers
+$f = HTML::FormatText::WithLinks->new( with_emphasis => 1, bold_marker => '*', italic_marker => '"' );
+ok($f, 'object created');
+$text = $f->parse($html);
+ok($text, 'html formatted');
+is($text, qq[   This is a mail of *some* "sort"\n\n   It has *some* of the "words" emphasised\n\n], 'html correctly formatted with emphasis');
+
 sub new_html {
 return <<'HTML';
 <html>




More information about the Pkg-perl-cvs-commits mailing list