From fc7bb8d564bf69ddeb4e276f72201f690d8063be Mon Sep 17 00:00:00 2001 From: nishanths Date: Wed, 25 Jun 2014 07:52:04 -0700 Subject: [PATCH] clean up html output tags --- lib/DDG/Goodie/HTMLEntitiesEncode.pm | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/DDG/Goodie/HTMLEntitiesEncode.pm b/lib/DDG/Goodie/HTMLEntitiesEncode.pm index b4a08bcbb..5c0ae62c2 100644 --- a/lib/DDG/Goodie/HTMLEntitiesEncode.pm +++ b/lib/DDG/Goodie/HTMLEntitiesEncode.pm @@ -6,7 +6,7 @@ use DDG::Goodie; use strict; use warnings; -# '&' and ';' not included in the hash value -- they are added in make_text and make_html +# '&' and ';' not included in the hash value -- they are added in make_text() and make_html() my %codes = ( # Punctuation 'en dash' => [['En dash', 'ndash']], @@ -69,7 +69,7 @@ my %codes = ( 'pipe' => [['Pipe', '#8214']], 'pipes' => [['Pipe', '#8214']], 'dagger' => [['Dagger','dagger']], - + 'bullet' => [['Bullet','#8226']], # Special/misc. 'macron' => [['Macron', '#175']], @@ -223,16 +223,16 @@ sub make_text { }; sub make_html { - # Returns a html formatted string with .class names only (no styles) + # Returns a html formatted string with css class names (no inline styles) my $html = qq(
); if (scalar(@{$_[0]}) == 1) { # single line answer - $html = qq(
Encoded HTML Entity (&$_[0][0][1];): &$_[0][0][1];
) ; # link in the same line for single line answers + $html = qq(
Encoded HTML Entity (&$_[0][0][1];): &$_[0][0][1];
) ; # link in the same line for single line answers } else { foreach my $i (0 .. scalar(@{$_[0]}) - 1) { # multiple line answer - $html = "$html" . qq(
$_[0][$i][0] (&$_[0][$i][1];): &$_[0][$i][1];
); + $html = "$html" . qq(
$_[0][$i][0] (&$_[0][$i][1];): &$_[0][$i][1];
); } - $html = $html . "
" - } + } + $html = $html . "" }; triggers startend => 'html encode','encode html','html escape','escape html','html entity','html code','html character code', @@ -254,9 +254,7 @@ attribution web => ["http://nishanths.github.io", "Nishanth Shanmugham" twitter => 'crazedpsyc', cpan => 'CRZEDPSYC' ; - handle remainder => sub { - # General query cleanup $_ =~ s/^\s+|\s+$//g; # remove front and back whitespace $_ =~ s/^(for|of)\s+//g; # remove filler words at the start (note: this will remove 'for' in "for euro sign", but not 'for' in "formula sign") @@ -298,7 +296,7 @@ handle remainder => sub { } # Query maybe a single typed-in character to encode - # No hits above if we got this far, try encode_entities() of HTML::Entities now + # No hits above if we got this far, use encode_entities() of HTML::Entities if (length($_) == 1){ my $entity = encode_entities($_); if ($entity eq $_) { # encode_entities() was unsuccessful and returned the input itself