hexojs/hexo-renderer-pandoc

Why it's <embed> instead of <img> tag?

zhaofei2048 opened this issue · 5 comments

When I insert an image in .md file:
[alt](http://mydomain.com/img.jpg)
Then generated HTML will be:
<embed src="http://mydomain.com/img.jpg">
Above is not what I want, and I think,it should be:
<img src="http://mydomain.com/img.jpg">
What can I do?Please help me, thankyou!

Sorry but I cannot reproduce your problem

I tested on the following .md file

[alt](http://mydomain.com/img.jpg)
[alt](http://mydomain.com/img.mp4)

![alt](http://mydomain.com/img.jpg)
![alt](http://mydomain.com/img.mp4)

(notice the different syntax for link and media, i think you have a typo in your issue report. Though judged by that you got a <embed> tag, you probablly correctly used the second syntax)

I got

<a target="_blank" rel="noopener" href="http://mydomain.com/img.jpg">alt</a>
<a target="_blank" rel="noopener" href="http://mydomain.com/img.mp4">alt</a>

<img src="http://mydomain.com/img.jpg" alt="alt" />
<video src="http://mydomain.com/img.mp4" controls=""><a target="_blank" rel="noopener" href="http://mydomain.com/img.mp4">alt</a></video>

as expected.

Actually, when I then went to my older machine with pandoc 2.11.1, for the video I got an image tag. So I suspect that your pandoc is even older than 2.11.1.

Hence, can you 1) report the version of pandoc caused your problem; 2) update pandoc and see if the issue is gone?

Looking at the source code of Pandoc, I see that pandoc inspects the extention of the url and generate HTML tags according to it, and does not give anyway to specify the MIME type. This matter is complicated because Pandoc decided to overload the markdown image syntax for audio/video and other things.

Moreover pandoc filter does not help, since the problem happens after filters are invoked.

So there seem only one way around the problem is this: hardcode the raw HTML tag <img src="http://mydomain.com/img.jpg-gz" alt="alt" /> in you .md file.

With this markdown

![alt](http://mydomain.com/img.jpg)
![alt](http://mydomain.com/img.mp4)
<img src="http://mydomain.com/img.jpg-gz" alt="alt" />

I got

<img src="http://mydomain.com/img.jpg" alt="alt" />
<video src="http://mydomain.com/img.mp4" controls=""><a target="_blank" rel="noopener" href="http://mydomain.com/img.mp4">alt</a></video>
<img src="http://mydomain.com/img.jpg-gz" alt="alt" />

Glad I resolved your issue. I'm closing this one now.

As for this:

the github flavoured task list (or called todo list) cannot be rendered correctly. However, the pandoc support this feature as they stated that in their mannual.

Can you open a new issue and provide a minimal reproducible example there?