Closed ChristopherJTrent closed 2 months ago
Oh fun fact, this continues to fail and be broken when I add INLINE CSS.
Nothing changes in normal browsers, but in here, no, even inline CSS is ignored.
The README has a section about debugging. If you load Grover specifying that you want to show the browser and essentially "pause" you will see the reason the CSS isn't loading in the console tab:
Grover.new(html, debug: { headless: false, devtools: true }, wait_for_selector: 'foo').to_jpeg('out.jpg'); nil
Specifically, Chrome won't load local files into a page that itself isn't a local file for security reasons. The way that you're loading the HTML into the browser (as a string) means that Chrome doesn't see it as being a local file.
I'll also note that the "CSS" file you've listed isn't CSS.. it appears to be SCSS.
Also note, if I dump your "CSS" into a style tag it is rendered just fine (well.. the styles that are actual CSS appear to render).
Please have a read of the README on how to use Grover, specifically the debugging section. Suggest also have a bit of a read about the differences between CSS and SCSS.
I've moved to Selenium webdrivers as they are more compatible with my use case. As for your comment about SCSS. My CSS is valid. I assume you're referring to the CSS nesting selector "&" which has been supported in all major browsers since the beginning of the year but is still seen as some kind of black magic by some. I'd suggest you take the time to understand what you're looking at before choosing to condescend.
https://caniuse.com/css-nesting 80% of the time it's valid every time.
I'd suggest that you try read the manual and debug things a little more yourself next time 😉 And if you're asking for help, and then get it.. a simple thank you is all that is needed 😄
I provided numerous suggestions and prompts to help you solve your problem and your response is to berate.. some self reflection wouldn't go astray
I don't have a rails app or anything fancy going on. All I'm trying to do is get a plain HTML file, that links to a CSS file, to render to a jpeg.
No matter what I do, up to and including giving an absolute path using the
file://
protocol, my stylesheets never apply to the output.Below are the entire contents of my project. These three files should, in my opinion, be all the code I should have to write in order to get a basic jpeg image out the other side, but no, this doesn't apply card_template.css
Edit for clarification: the html file works perfectly fine in normal Chrome, Microsoft Edge, and Firefox. It's just Grover that can't handle it.
renderer.rb
card_template.html
card_template.css