[Rt-commit] rt branch, 4.2/html-external-formatter, repushed

Alex Vandiver alexmv at bestpractical.com
Mon Jun 16 17:24:50 EDT 2014


The branch 4.2/html-external-formatter was deleted and repushed:
       was 20d34db491141fb338453321b221d0b92e671f15
       now 9b6ff366ff6aa71df8e2ae857a4fa931e15c5b00

1:  8fc3d11 ! 1:  b95b986 Use HTML::FormatExternal to allow external HTML → text formatters
    @@ -15,13 +15,14 @@
      
      Set($ForwardFromUser, 0);
      
    -+=item C<@HTMLFormatters>
    ++=item C<$HTMLFormatter>
     +
    -+The order of external HTML formatters to look for; programs which are
    -+not found to be installed will be skipped.  C<core> is the internal perl
    -+converter, which is significantly faster than the others, but may fail
    -+to successfully convert even on some relatively simple HTML.  Falls back
    -+to C<core> if no explicitly listed option is available.
    ++The external HTML formatter to use.  The default is to try, in order,
    ++C<w3m>, C<elinks>, C<html2text>, C<links>, C<lynx>, and then fall back
    ++to the C<core> pure-perl formatter.  The pure-perl formatter is
    ++significantly faster than the others, but may fail to successfully
    ++convert even on some relatively simple HTML.  Falls back to C<core> if
    ++the configured program is not installed.
     +
     +Using formatters other than C<core> requires that the
     +L<HTML::FormatExternal> module be installed; it is an optional
    @@ -29,7 +30,7 @@
     +
     +=cut
     +
    -+Set(@HTMLFormatters, "w3m", "elinks", "html2text", "links", "lynx", "core");
    ++Set($HTMLFormatter, undef);
     +
      =back
      
    @@ -42,8 +43,8 @@
                  $self->Set( MailCommand => 'sendmailpipe' );
              },
          },
    -+    HTMLFormatters => {
    -+        Type => 'ARRAY',
    ++    HTMLFormatter => {
    ++        Type => 'SCALAR',
     +        PostLoadCheck => sub { RT::Interface::Email->_HTMLFormatter },
     +    },
          MailPlugins  => {
    @@ -80,17 +81,32 @@
     +    state $formatter;
     +    return $formatter if defined $formatter;
     +
    -+    my @order = RT->Config->Get("HTMLFormatters");
    ++    my $wanted = RT->Config->Get("HTMLFormatter");
    ++
    ++    my @order;
    ++    if ($wanted) {
    ++        @order = ($wanted, "core");
    ++    } else {
    ++        @order = ("w3m", "elinks", "html2text", "links", "lynx", "core");
    ++    }
     +    # Always fall back to core, even if it is not listed
    -+    for my $prog (@order, "core") {
    ++    for my $prog (@order) {
     +        if ($prog eq "core") {
     +            RT->Logger->info("Using internal Perl HTML -> text conversion");
     +            require HTML::FormatText::WithLinks::AndTables;
     +            $formatter = \&_HTMLFormatText;
     +        } else {
     +            my $package = "HTML::FormatText::" . ucfirst($prog);
    -+            $package->require or next;
    -+            next unless defined $package->program_version;
    ++            unless ($package->require) {
    ++                RT->Logger->warn("Could not load $package; install HTML::FormatExternal")
    ++                    if $wanted;
    ++                next;
    ++            }
    ++            unless (defined $package->program_version) {
    ++                RT->Logger->warn("Could not find external '$prog' HTML formatter; is it installed?")
    ++                    if $wanted;
    ++                next;
    ++            }
     +
     +            RT->Logger->info("Using $prog for HTML -> text conversion");
     +            $formatter = sub {
    @@ -100,7 +116,7 @@
     +                };
     +            };
     +        }
    -+        RT->Config->Set( HTMLFormatters => [$prog] );
    ++        RT->Config->Set( HTMLFormatter => $prog );
     +        last;
     +    }
     +    return $formatter;
2:  953e238 ! 2:  61cd55e Add HTML::HTML5::ToText as a better pure-perl HTML → text converter
    @@ -6,15 +6,19 @@
     --- a/etc/RT_Config.pm.in
     +++ b/etc/RT_Config.pm.in
     @@
    - The order of external HTML formatters to look for; programs which are
    - not found to be installed will be skipped.  C<core> is the internal perl
    - converter, which is significantly faster than the others, but may fail
    --to successfully convert even on some relatively simple HTML.  Falls back
    --to C<core> if no explicitly listed option is available.
    -+to successfully convert even on some relatively simple HTML.  C<perl> is
    -+a somewhat improved perl-based converter, but requires an optional
    -+module.  Falls back to C<core> if no explicitly listed option is
    -+available.
    + 
    + =item C<$HTMLFormatter>
    + 
    +-The external HTML formatter to use.  The default is to try, in order,
    +-C<w3m>, C<elinks>, C<html2text>, C<links>, C<lynx>, and then fall back
    +-to the C<core> pure-perl formatter.  The pure-perl formatter is
    ++The external HTML formatter to use.  The default is to try, in order, an
    ++improved perl formatter (C<perl>), the external programs C<w3m>,
    ++C<elinks>, C<html2text>, C<links>, or C<lynx>, and then fall back to the
    ++C<core> pure-perl formatter.  The C<perl> and C<core> formatters are
    + significantly faster than the others, but may fail to successfully
    + convert even on some relatively simple HTML.  Falls back to C<core> if
    + the configured program is not installed.
      
     -Using formatters other than C<core> requires that the
     -L<HTML::FormatExternal> module be installed; it is an optional
    @@ -26,11 +30,6 @@
      
      =cut
      
    --Set(@HTMLFormatters, "w3m", "elinks", "html2text", "links", "lynx", "core");
    -+Set(@HTMLFormatters, "perl", "w3m", "elinks", "html2text", "links", "lynx", "core");
    - 
    - =back
    - 
     
     diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
     --- a/lib/RT/Interface/Email.pm
    @@ -40,7 +39,11 @@
                  require HTML::FormatText::WithLinks::AndTables;
                  $formatter = \&_HTMLFormatText;
     +        } elsif ($prog eq "perl") {
    -+            HTML::HTML5::ToText->require or next;
    ++            unless (HTML::HTML5::ToText->require) {
    ++                RT->Logger->warn("Could not load HTML::HTML5::ToText; install it from CPAN")
    ++                    if $wanted;
    ++                next;
    ++            }
     +            my $obj = HTML::HTML5::ToText->new_with_traits(
     +                traits => [qw/ShowLinks ShowImages RenderTables TextFormatting/],
     +            );
    @@ -55,5 +58,5 @@
     +            };
              } else {
                  my $package = "HTML::FormatText::" . ucfirst($prog);
    -             $package->require or next;
    +             unless ($package->require) {
     
3:  dd1829a = 3:  4647de4 HTML::HTML5::ToText mistakenly installs a global __WARN__ handler; local it
4:  20d34db = 4:  9b6ff36 Update tests to work with any of the HTML formatters



More information about the rt-commit mailing list