HTMLEntitiesDecode: Fixing the actual display; content isn't required for the Text template; also removing html_enc so that things are displayed correctly
parent
07ecf6867a
commit
e6810b754c
|
@ -47,14 +47,11 @@ handle remainder => sub {
|
||||||
return "Decoded HTML Entity: $decoded",
|
return "Decoded HTML Entity: $decoded",
|
||||||
structured_answer => {
|
structured_answer => {
|
||||||
data => {
|
data => {
|
||||||
title => html_enc($decoded),
|
title => $decoded,
|
||||||
subtitle => 'HTML Entity Decode: '.html_enc($_)
|
subtitle => 'HTML Entity Decode: '.$_
|
||||||
},
|
},
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text',
|
||||||
options => {
|
|
||||||
content => 'DDH.html_entity.content'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
@ -18,10 +18,7 @@ sub build_structured_answer {
|
||||||
subtitle => $subtitle,
|
subtitle => $subtitle,
|
||||||
},
|
},
|
||||||
templates => {
|
templates => {
|
||||||
group => 'text',
|
group => 'text'
|
||||||
options => {
|
|
||||||
content => 'DDH.html_entity.content'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -35,32 +32,32 @@ ddg_goodie_test(
|
||||||
[qw(DDG::Goodie::HTMLEntitiesDecode)],
|
[qw(DDG::Goodie::HTMLEntitiesDecode)],
|
||||||
|
|
||||||
# Simple decimal test
|
# Simple decimal test
|
||||||
'html decode !' => build_test("Decoded HTML Entity: !", "!", "HTML Entity Decode: !"),
|
'html decode !' => build_test("Decoded HTML Entity: !", "!", "HTML Entity Decode: !"),
|
||||||
# Simple text test
|
# Simple text test
|
||||||
'html entity &' => build_test("Decoded HTML Entity: &", "&","HTML Entity Decode: &"),
|
'html entity &' => build_test("Decoded HTML Entity: &", "&","HTML Entity Decode: &"),
|
||||||
# Another simple text test
|
# Another simple text test
|
||||||
'decode html for >' => build_test("Decoded HTML Entity: >", ">","HTML Entity Decode: >"),
|
'decode html for >' => build_test("Decoded HTML Entity: >", ">","HTML Entity Decode: >"),
|
||||||
# Simple hex test
|
# Simple hex test
|
||||||
'! htmlentity' => build_test("Decoded HTML Entity: !", "!","HTML Entity Decode: &#x21"),
|
'! htmlentity' => build_test("Decoded HTML Entity: !", "!","HTML Entity Decode: !"),
|
||||||
|
|
||||||
# No "&" and ";" in decimal input
|
# No "&" and ";" in decimal input
|
||||||
'#36 html decode' => build_test('Decoded HTML Entity: $', '$',"HTML Entity Decode: #36"),
|
'#36 html decode' => build_test('Decoded HTML Entity: $', '$',"HTML Entity Decode: #36"),
|
||||||
# Variety in hex queries
|
# Variety in hex queries
|
||||||
'" decodehtml' => build_test('Decoded HTML Entity: "', '"',"HTML Entity Decode: &#X22"),
|
'" decodehtml' => build_test('Decoded HTML Entity: "', '"',"HTML Entity Decode: ""),
|
||||||
# More variety in hex queries
|
# More variety in hex queries
|
||||||
'htmlentity for #x3c' => build_test("Decoded HTML Entity: <", "<","HTML Entity Decode: #x3c"),
|
'htmlentity for #x3c' => build_test("Decoded HTML Entity: <", "<","HTML Entity Decode: #x3c"),
|
||||||
|
|
||||||
# "¢" succeeds
|
# "¢" succeeds
|
||||||
'html decode ¢' => build_test(qr/.*/, "¢","HTML Entity Decode: &cent;"),
|
'html decode ¢' => build_test("Decoded HTML Entity: ¢", '¢',"HTML Entity Decode: ¢"),
|
||||||
# "¢" also succeeds (missing back ";" is OK)
|
# "¢" also succeeds (missing back ";" is OK)
|
||||||
'html decode ¢' => build_test(qr/.*/, "¢","HTML Entity Decode: &cent"),
|
'html decode ¢' => build_test("Decoded HTML Entity: ¢", '¢',"HTML Entity Decode: ¢"),
|
||||||
# "cent" fails during the regex match because of the missing front "&" (stricter for text to eliminate false positive encoding hits)
|
# "cent" fails during the regex match because of the missing front "&" (stricter for text to eliminate false positive encoding hits)
|
||||||
'html decode cent' => undef,
|
'html decode cent' => undef,
|
||||||
# "cent;" fails during the regex match for the same reasons as above
|
# "cent;" fails during the regex match for the same reasons as above
|
||||||
'html decode cent;' => undef,
|
'html decode cent;' => undef,
|
||||||
|
|
||||||
# "" has no visual representation
|
# "" has no visual representation
|
||||||
'html entity of ' => build_test("Decoded HTML Entity: Unicode control character (no visual representation)", "Unicode control character (no visual representation)","HTML Entity Decode: &#20;"),
|
'html entity of ' => build_test("Decoded HTML Entity: Unicode control character (no visual representation)", "Unicode control character (no visual representation)","HTML Entity Decode: "),
|
||||||
|
|
||||||
# Querying for "&bunnyrabbit;" should fail
|
# Querying for "&bunnyrabbit;" should fail
|
||||||
'html decode &bunnyrabbit;' => undef,
|
'html decode &bunnyrabbit;' => undef,
|
||||||
|
@ -70,12 +67,12 @@ ddg_goodie_test(
|
||||||
'html decode apostrophe' => undef,
|
'html decode apostrophe' => undef,
|
||||||
|
|
||||||
# natural querying
|
# natural querying
|
||||||
'What is the decoded html entity for π?' => build_test("Decoded HTML Entity: π", "π","HTML Entity Decode: &#960;"),
|
'What is the decoded html entity for π?' => build_test("Decoded HTML Entity: π", "π","HTML Entity Decode: π"),
|
||||||
|
|
||||||
# natural querying
|
# natural querying
|
||||||
'what is decoded html entity for #960 ?' => build_test("Decoded HTML Entity: π", "π","HTML Entity Decode: #960"),
|
'what is decoded html entity for #960 ?' => build_test("Decoded HTML Entity: π", "π","HTML Entity Decode: #960"),
|
||||||
# no "html" in query
|
# no "html" in query
|
||||||
'the decoded entity for ō is?' => build_test("Decoded HTML Entity: ō", "ō","HTML Entity Decode: &#333;"),
|
'the decoded entity for ō is?' => build_test("Decoded HTML Entity: ō", "ō","HTML Entity Decode: ō"),
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
Loading…
Reference in New Issue