Open rushiagr opened 11 years ago
OK. Now its erring when I do this too:
Pynliner().from_string(all_lines).run()
where all_lines is contains strings of an html file which has links to local stylesheets.
Looks like a minor issue, but an issue nevertheless.
The log:
>>> Pynliner().from_string(all_lines).run()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pynliner/__init__.py", line 112, in run
self._get_styles()
File "/usr/local/lib/python2.7/dist-packages/pynliner/__init__.py", line 141, in _get_styles
self._get_external_styles()
File "/usr/local/lib/python2.7/dist-packages/pynliner/__init__.py", line 164, in _get_external_styles
url = self.relative_url + url
AttributeError: 'Pynliner' object has no attribute 'relative_url'
You're right. Pynliner doesn't support loading stylesheets from relative urls when the html is passed as a string. This is because it needs to know how to look them up when starting with the relative url.
This issue could be solved by specifying a filesystem root for where to look for referenced files or by registering filenames and file content strings with Pynliner.
I personally don't have time to go after either of those at the moment but I'll accept pull requests!
When I tried to parse an HTML which has a local css file, it generated this error
Looks like the variable 'relative_url' is not defined when a call from function other than from_url() is made. To be more clear, when one tries to do a
Pynliner().from_string(html_string).with_cssString(css_string).run()
where thehtml_string
already contains a 'link' to a local stylesheet, it generates this error.For starters, it might be confusing to see this error. A newbie, in the absence of guiding documentation, might want to pass the stringified css file to the stringified html file, where the html file already contained a link to that css file locally