public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: "cjns...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
	<cjns1989-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	pandoc-discuss
	<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: image that resizes automatically to screen size in epub
Date: Wed, 28 Oct 2020 17:21:47 -0700	[thread overview]
Message-ID: <m2zh45swys.fsf@MacBook-Pro.hsd1.ca.comcast.net> (raw)
In-Reply-To: <m25z6tuc4a.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>

John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:

> "cjns...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <cjns1989-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>> Here's the code:
>>
>> <div id="pl01">
>> <svg xmlns="http://www.w3.org/2000/svg" 
>> xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" 
>> height="100%" viewBox="0 0 900 1200" preserveAspectRatio="none">
>> <image width="900" height="1200" xlink:href="../media/pl001.jpg" />
>> </svg>
>> </div>
>>
>> The jpg image is invoked via "xlink:href=" 
>>
>> Unless I'm getting confused with the relative path the nightly version 
>> still does not pull the referenced file: it's nowhere to be found either in 
>> the EPUB/content.opf manifest nor does it get copied over to EPUB/media/*
>>
>> On the other hand pandoc does understand the <svg></svg> tag: in the 
>> content.opf manifest of the resulting EPUB the description of the 
>> ch001.xhtml that contains the above code includes the "properties=svg" 
>> attribute.
>>   
>> My guess is that pandoc does not understand the "xlink:ref="  syntax.
>
> That's right. It probably wouldn't hurt just to globally allow this as a
> fallback if src isn't present.

Hm. The raw HTML is passed through to the EPUB (at least in
current master with the svg fix). The problem is that pandoc
doesn't "see" the jpg and thus doesn't include it in the manifest
or media.  That's because the SVG lives in the AST as a raw HTML
element, not an Image, and pandoc only fetches contents for
Images.

The change I referred to earlier causes svg elements in HTML
to be parsed as images (with data: urls encoding the SVG
content).  But it only does that if `raw_html` is disabled
in the reader. If `raw_html` is enabled, it just parses
the SVG element as raw HTML.  The problem is that your input
source is Markdown, not HTML, and the only thing the Markdown
reader does with HTML is return raw HTML blocks/inlines.
(It does not try to parse this HTML and assign it a meaning.)

You can work around this, actually!

% pandoc -f html -t markdown
<svg xmlns="http://www.w3.org/2000/svg" 
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" 
height="100%" viewBox="0 0 900 1200" preserveAspectRatio="none">
<image width="900" height="1200" xlink:href="../media/pl001.jpg" />
</svg>
^D
![](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdib3g9IjAgMCA5MDAgMTIwMCIgcHJlc2VydmVhc3BlY3RyYXRpbz0ibm9uZSI+CjxpbWFnZSB3aWR0aD0iOTAwIiBoZWlnaHQ9IjEyMDAiIGhyZWY9Ii4uL21lZGlhL3BsMDAxLmpwZyI+PC9pbWFnZT4KPC9zdmc+)

Just include that Markdown image tag in your document instead of
the HTML svg element, and everything should work properly (with
the pandoc nightly).

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2zh45swys.fsf%40MacBook-Pro.hsd1.ca.comcast.net.


  parent reply	other threads:[~2020-10-29  0:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-14 22:15 Chris Jones
     [not found] ` <b49a95c6-772c-43ac-9bc5-0011ed206c38o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-06 19:50   ` Chris Jones
2020-10-06 22:15   ` Charles Richer Saint-Faure
     [not found]     ` <a0514cc8-560e-40b2-802e-aed2b58930a8o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-07  4:45       ` John MacFarlane
2020-10-26 19:06   ` Chris Jones
     [not found]     ` <220286f4-8dab-4a80-9ad6-4794e15f1961o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-26 21:17       ` John MacFarlane
     [not found]         ` <m27drcoffg.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-10-28 18:31           ` cjns...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found]             ` <04e6652d-6db6-4090-b2f1-db7acc33edd2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-29  0:09               ` John MacFarlane
     [not found]                 ` <m25z6tuc4a.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-10-29  0:21                   ` John MacFarlane [this message]
     [not found]                     ` <m2zh45swys.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-10-31 20:34                       ` cjns...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found]                         ` <20201031203402.gutswizwu477rh3y-611mE6nXTcHDOqzlkpFKJg@public.gmane.org>
2020-10-31 22:59                           ` John MacFarlane
  -- strict thread matches above, loose matches on Subject: below --
2020-06-12 20:00 Chris Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2zh45swys.fsf@MacBook-Pro.hsd1.ca.comcast.net \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=cjns1989-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).