Problems imbedding images without format suffix

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems imbedding images without format suffix

oddhack
I'm trying to do math in a document by imbedding an image generated by a remote service, such as

image:https://render.githubusercontent.com/render/math?math=\displaystyle \text{b} = V D[]

In the HTML5 renderer, this works. In asciidoctor-pdf (using -a allow-uri-read, of course), I get a message like this:

> asciidoctor: WARNING: could not embed image: /tmp/image-20201112-19102-165jx60; image file is an unrecognised format

Capturing the returned image, it's just normal SVG. If I take that returned image and name it e.g. 'foo.svg' and feed that into asciidoctor as an image (HTML5 or PDF), it works fine. But if I name it in the same fashion as the WARNING, e.g. 'image-20201112-19102-165jx60', and feed that into asciidoctor as an image, I get the exact same WARNING from asciidoctor-pdf - and, although there is no warning or error message, the HTML5 renderer generates a broken-image link.

I infer that asciidoctor usually, though not always, requires an image format suffix on the source argument of image: to determine how to process it. There do not appear to be any options for the image: directive that allow specifying the format explicitly. There's no apparent reason the asciidoctor component (or external ruby gem?) fetching the image couldn't name it properly or otherwise recognize the format; the HTTP headers returned from the render server label it 'Content-Type: image/svg+xml' so that information is available, just apparently not being used.

Any thoughts on how to proceed?

Jon
Reply | Threaded
Open this post in threaded view
|

Re: Problems imbedding images without format suffix

mojavelinux
Administrator
Jon,

If the target does not end in a file extension, then the processor cannot infer the format. In that case, you can define the format explicitly using the format attribute:

image::https://render.githubusercontent.com/render/math?math=\displaystyle \text{b} = V D[format=svg]

Specifying the format is only necessary if the converter needs to know it. SVG is one of those cases.

Best Regards,

-Dan

p.s. I did not realize that GitHub had an API to render LaTeX math. We could make use of that to render LaTeX math on GitHub.

On Thu, Nov 12, 2020 at 6:28 AM oddhack [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I'm trying to do math in a document by imbedding an image generated by a remote service, such as

image:https://render.githubusercontent.com/render/math?math=\displaystyle \text{b} = V D[]

In the HTML5 renderer, this works. In asciidoctor-pdf (using -a allow-uri-read, of course), I get a message like this:

> asciidoctor: WARNING: could not embed image: /tmp/image-20201112-19102-165jx60; image file is an unrecognised format

Capturing the returned image, it's just normal SVG. If I take that returned image and name it e.g. 'foo.svg' and feed that into asciidoctor as an image (HTML5 or PDF), it works fine. But if I name it in the same fashion as the WARNING, e.g. 'image-20201112-19102-165jx60', and feed that into asciidoctor as an image, I get the exact same WARNING from asciidoctor-pdf - and, although there is no warning or error message, the HTML5 renderer generates a broken-image link.

I infer that asciidoctor usually, though not always, requires an image format suffix on the source argument of image: to determine how to process it. There do not appear to be any options for the image: directive that allow specifying the format explicitly. There's no apparent reason the asciidoctor component (or external ruby gem?) fetching the image couldn't name it properly or otherwise recognize the format; the HTTP headers returned from the render server label it 'Content-Type: image/svg+xml' so that information is available, just apparently not being used.

Any thoughts on how to proceed?

Jon



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Problems-imbedding-images-without-format-suffix-tp8342.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Problems imbedding images without format suffix

mojavelinux
Administrator
In reply to this post by oddhack
> There's no apparent reason the asciidoctor component (or external ruby gem?) fetching the image couldn't name it properly or otherwise recognize the format

This was never a goal of the Asciidoctor processor. If someone wants to propose that change, I'd be open to reviewing it.

-Dan

On Thu, Nov 12, 2020 at 2:43 PM Dan Allen <[hidden email]> wrote:
Jon,

If the target does not end in a file extension, then the processor cannot infer the format. In that case, you can define the format explicitly using the format attribute:

image::https://render.githubusercontent.com/render/math?math=\displaystyle \text{b} = V D[format=svg]

Specifying the format is only necessary if the converter needs to know it. SVG is one of those cases.

Best Regards,

-Dan

p.s. I did not realize that GitHub had an API to render LaTeX math. We could make use of that to render LaTeX math on GitHub.

On Thu, Nov 12, 2020 at 6:28 AM oddhack [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I'm trying to do math in a document by imbedding an image generated by a remote service, such as

image:https://render.githubusercontent.com/render/math?math=\displaystyle \text{b} = V D[]

In the HTML5 renderer, this works. In asciidoctor-pdf (using -a allow-uri-read, of course), I get a message like this:

> asciidoctor: WARNING: could not embed image: /tmp/image-20201112-19102-165jx60; image file is an unrecognised format

Capturing the returned image, it's just normal SVG. If I take that returned image and name it e.g. 'foo.svg' and feed that into asciidoctor as an image (HTML5 or PDF), it works fine. But if I name it in the same fashion as the WARNING, e.g. 'image-20201112-19102-165jx60', and feed that into asciidoctor as an image, I get the exact same WARNING from asciidoctor-pdf - and, although there is no warning or error message, the HTML5 renderer generates a broken-image link.

I infer that asciidoctor usually, though not always, requires an image format suffix on the source argument of image: to determine how to process it. There do not appear to be any options for the image: directive that allow specifying the format explicitly. There's no apparent reason the asciidoctor component (or external ruby gem?) fetching the image couldn't name it properly or otherwise recognize the format; the HTTP headers returned from the render server label it 'Content-Type: image/svg+xml' so that information is available, just apparently not being used.

Any thoughts on how to proceed?

Jon



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Problems-imbedding-images-without-format-suffix-tp8342.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Problems imbedding images without format suffix

oddhack
In reply to this post by mojavelinux
Thanks! The image: format attribute is not defined in the User Guide (section 29.5), AFAICT, but I was hoping one existed.

Regarding render.githubusercontent.com site, I think it was more or less an accidental discovery by someone that this functionality exists for other purposes - https://gist.github.com/a-rodin/fef3f543412d6e1ec5b6cf55bf197d7b . It seems to be undocumented and probably not a robust site to rely on (they might easily decide to block access from outside their intended userbase, for example), though it is useful.

Jon
Reply | Threaded
Open this post in threaded view
|

Re: Problems imbedding images without format suffix

mojavelinux
Administrator
Jon,

We're in the process of rewriting all the docs. I'll make sure the format attribute on the image macros gets included.

That's for the info about the render service.

Best Regards,

-Dan

On Thu, Nov 12, 2020 at 3:34 PM oddhack [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thanks! The image: format attribute is not defined in the User Guide (section 29.5), AFAICT, but I was hoping one existed.

Regarding render.githubusercontent.com site, I think it was more or less an accidental discovery by someone that this functionality exists for other purposes - https://gist.github.com/a-rodin/fef3f543412d6e1ec5b6cf55bf197d7b . It seems to be undocumented and probably not a robust site to rely on (they might easily decide to block access from outside their intended userbase, for example), though it is useful.

Jon



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Problems-imbedding-images-without-format-suffix-tp8342p8345.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Problems imbedding images without format suffix

mojavelinux
Administrator


That's for the info about the render service.

I meant to say "Thanks for the info..."

-Dan


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux