From 17a063860b499a0fcf7b70c6f37b00d3a6ffb0d2 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 11 Apr 2015 14:57:02 +0300 Subject: [PATCH] Parse and reserialize literal HTML --- lib/Plack/App/Gruntmaster/HTML.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Plack/App/Gruntmaster/HTML.pm b/lib/Plack/App/Gruntmaster/HTML.pm index ebbc145..3cfbc54 100644 --- a/lib/Plack/App/Gruntmaster/HTML.pm +++ b/lib/Plack/App/Gruntmaster/HTML.pm @@ -10,7 +10,12 @@ use POSIX qw//; use Data::Dumper qw/Dumper/; sub ftime ($) { POSIX::strftime '%c', localtime shift } -sub literal ($) { HTML::Element::Library::super_literal shift // '' } +sub literal ($) { + my $b = HTML::TreeBuilder->new; + $b->ignore_unknown(0); + $b->parse(shift // ''); + HTML::Element::Library::super_literal $b->guts->as_HTML; +} sub HTML::Element::edit_href { my ($self, $sub) = @_; -- 2.39.2