Skip Menu |

This queue is for tickets about the CSS-Inliner CPAN distribution.

Report information
The Basics
Id: 58957
Status: resolved
Priority: 0/
Queue: CSS-Inliner

People
Owner: Nobody in particular
Requestors: wonko [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2544
Fixed in: (no value)



Subject: Incorrect error if HTML being inlined has no style blocks
If the HTML you are trying to inline doesn't have any style blocks, then CSS::Inliner dies, when instead it should probably just not do anything. For example, this: my $inliner = CSS::Inliner->new(); $inliner->read({html => "<html><body><p>blah, blah</p></body></html>"}); $inliner->inlinify; Dies with this error message: You must instantiate and read in your content before inlinifying The attached patch fixes this to just return the original HTML if no CSS is detected in the document.
Subject: html_without_css.patch
--- Inliner.pm.orig 2010-06-29 17:40:54.148895876 -0400 +++ Inliner.pm 2010-06-29 17:43:05.796923500 -0400 @@ -132,7 +132,8 @@ #the remaining html tree has no style block(s) now my $style = $self->_get_style({tree_content => $tree->content()}); - #stash the stylesheets + #stash the data + $self->{html} = $$params{html}; $self->{css} = $style; return(); @@ -159,10 +160,12 @@ croak "You must instantiate this class in order to properly use it"; } - unless ($self->{css} && $self->{html_tree}) { + unless ($self->{html} && $self->{html_tree}) { croak "You must instantiate and read in your content before inlinifying"; } + return $self->{html} unless $self->{css}; + #parse and store the stylesheet as a hash object my $css = CSS::Tiny->read_string($self->{css});
Hi Michael, Yeah that is pretty dumb that it croaks like that - I've taken your patch, modified it slightly and merged it into our SVN. I'm going to be releasing within a day or two code that includes your fixes as well as a new option of mine. Look for it shortly, and thanks again for the contributions -Kevin