Open Try2Code opened 2 years ago
This gems does work well with URL. But there's a rescue
and retry
that would hide the first error, which is the one you're probably trying to fix @Try2Code .
See the code:
img_dirs = @options.fetch(:image_directories, []) + ["."]
path_or_url = img.attr["src"]
begin
image_obj, image_info = @pdf.build_image_object(open(path_or_url))
rescue StandardError => e
puts "ERROR: #{e}"
raise if img_dirs.empty?
path_or_url = File.join(img_dirs.shift, img.attr["src"])
retry
end
On the first try your open
call is likely failing. Then it rescue
the error, change the path_or_url
variable joining the img_dirs
content and try again. Given that img_dirs
will always have a "."
it sounds like the error is related to the fact that ConverterPdf is looking locally for a URL, but that's false. Looking locally by joining the img_dirs
is just a fallback in case the URL fails.
I had the same problem, and adding a little bit of extra logging I could figure out what was my issue. In my case, the external image was returning a 404.
begin
image_obj, image_info = @pdf.build_image_object(open(path_or_url))
rescue StandardError => e
puts "ERROR: #{e}" # Extra logging
raise if img_dirs.empty?
path_or_url = File.join(img_dirs.shift, img.attr["src"])
retry
end
hi!
I would like to know if there is a way to convert markdown to pdf with inline images like
At the moment the converter seems to assume local files