Closed michaelrussell4 closed 10 months ago
Hello, thank you for addressing this issue. I noticed the fix uses string manipulation to split the file name.
Could I suggest a slightly more robust approach using os.path.splitext
?
It's specifically designed for splitting file names and extensions and might be better suited for this purpose.
In retrospective, this is how I should have done it from the start ...
Here's a possible implementation:
base_name, _ = os.path.splitext(name)
html_filename = base_name + '.html'
Thanks for considering this suggestion, this could be done via a new commit or a different PR.
Of course, that's even better.
K I committed the change you suggested in my PR.
File names with periods in them don't work because the html2image.py currently splits the file name on the first period, assuming there is only one such as in
filename.png
for files in thesave_as
list. But for a file name such asfile.name.with.periods.png
it breaks because it converts it tofile.html
(`html_filename = name.split('.')[0] + '.html'). This is a huge problem when directories have periods in them because then the paths get ruined.becomes
Simple fix. Just change the code to split only on the last period.