From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: why prepend "file://" to abs paths in html output? Date: Mon, 10 Jul 2017 21:44:42 +0000 Message-ID: References: <87lgnz43qk.fsf@nicolasgoaziou.fr> <87h8yn3tsa.fsf@nicolasgoaziou.fr> <87bmou4u8a.fsf@nicolasgoaziou.fr> <874lumfqk7.fsf@gmail.com> <877ezh51ns.fsf@nicolasgoaziou.fr> <86y3rw2y1y.fsf@hierocles.phy.bnl.gov> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a1141123042f4d30553fd7e2d" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUgUC-0006Mn-NI for emacs-orgmode@gnu.org; Mon, 10 Jul 2017 17:44:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUgUB-0002E2-Ij for emacs-orgmode@gnu.org; Mon, 10 Jul 2017 17:44:56 -0400 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:34351) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUgUB-0002D8-6a for emacs-orgmode@gnu.org; Mon, 10 Jul 2017 17:44:55 -0400 Received: by mail-lf0-x22d.google.com with SMTP id t72so71833297lff.1 for ; Mon, 10 Jul 2017 14:44:55 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Brett Viren , Nicolas Goaziou Cc: Carsten Dominik , Tim Cross , Org Mode --001a1141123042f4d30553fd7e2d Content-Type: text/plain; charset="UTF-8" Hello, On Mon, Jul 10, 2017 at 3:54 PM Kaushal Modi wrote: > Hi Nicolas, > > I tried out the patch, and my comments are in the MWE below. > > I have this MWE that explains the "would like to have" vs "what this patch > gives us": > > ===== > #+TITLE: ox-html root dir > #+OPTIONS: toc:nil > #+STARTUP: inlineimages > #+HTML_LINK_ROOT: /tmp/site/static/ > > An =image.png= exists as =/tmp/site/static/images/image.png=. > > * This is how the image links should have worked with the link root > already specified > [[/images/image.png]] > - The =HTML_LINK_ROOT= should to appended to the front of the above link > if that > concatenated path is a valid one. > - Would also like =C-x C-o=, inline image display, etc. to work. > - So a thought.. should the link root specification be made exporter > agnostic? > To expand on my MWE: I have this patch on top of Nicolas's patch: ===== diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 9e710e3e0a..410bb42eec 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -3011,11 +3011,12 @@ INFO is a plist holding contextual information. See ((file-name-absolute-p raw-path) (let ((root (plist-get info :html-link-root))) (setq raw-path - (if (and root (file-in-directory-p raw-path root)) - (concat "/" - (file-relative-name - (expand-file-name raw-path) - root)) + (if (and root + (file-exists-p + (concat (file-name-as-directory root) + (replace-regexp-in-string + "\\`/" "" raw-path)))) + raw-path (org-export-file-uri raw-path))))) ((and home use-abs-url) (setq raw-path (expand-file-name raw-path home)))) ===== This adds the root and link instead of having the root be a subset of link (hope that makes sense). With that, here is the updated MEW: ===== #+TITLE: ox-html root dir #+OPTIONS: toc:nil #+STARTUP: inlineimages #+HTML_LINK_ROOT: /tmp/site/static/ An =image.png= exists at =/tmp/site/static/images/image.png=. * TODO [1/2] This is how the image links should have worked with the link root already specified [[/images/image.png]] - [X] The =HTML_LINK_ROOT= should to appended to the front of the above link if that concatenated path is a valid one. - [ ] Would also like =C-x C-o=, inline image display, etc. to work. - So a thought.. should the link root specification be made exporter agnostic? ===== -- Kaushal Modi --001a1141123042f4d30553fd7e2d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

On Mon, Jul 10, 2017 at 3:54 PM Kaushal Modi <kaushal.modi@gmail.com> wrote:
Hi Nic= olas,

I tried out the patch, and my comments are i= n the MWE below.

<= div>I have this MWE that explains the "would like to have" vs &qu= ot;what this patch gives us":

=3D=3D=3D=3D=3D=
#+TITLE: ox-html root dir
#+OPTIONS: toc:nil
#+STARTUP: inlineimages
#+HTML_LINK_ROOT: /tmp/site/static/=

An =3Dimage.png=3D exists as =3D/tmp/site/static/= images/image.png=3D.

* This is how the image links= should have worked with the link root already specified
[[/image= s/image.png]]
- The =3DHTML_LINK_ROOT=3D should to appended to th= e front of the above link if that
=C2=A0 concatenated path is a v= alid one.
- Would also like =3DC-x C-o=3D, inline image display, = etc. to work.
- So a thought.. should the link root specification= be made exporter agnostic?

To expand on my MWE:

I have this patch on= top of Nicolas's patch:

=3D=3D=3D=3D=3D
=
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 9e710e3= e0a..410bb42eec 100644
--- a/lisp/ox-html.el
+++ b/lisp= /ox-html.el
@@ -3011,11 +3011,12 @@ INFO is a plist holding conte= xtual information.=C2=A0 See
=C2=A0 =C2=A0 =C2=A0 ((file-name-absolute-p raw-path)
=C2=A0<= span style=3D"white-space:pre"> =C2=A0 =C2=A0 =C2=A0(let ((root (pl= ist-get info :html-link-root)))
=C2=A0 (setq raw-path
- <= /span> =C2=A0 =C2=A0 =C2=A0(if (and root (file-in-directory-p raw-path root= ))
- =C2=A0(concat &quo= t;/"
- =C2=A0(fil= e-relative-name
- =C2= =A0 (expand-file-name raw-path)
-= =C2=A0 root))
+ =C2=A0 =C2=A0 =C2=A0(if (and root
+ =C2=A0 =C2=A0 =C2=A0 (file-exists-p
+ (concat (file-name-as-directory root)
=
+ (replace-regexp-in-string=
+ "\\`/" &= quot;" raw-path))))
+ =C2=A0raw-path
=C2=A0 (org-export-file-uri raw-path)))))
=C2=A0 =C2=A0 =C2=A0 ((and home use-abs-url)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(setq raw-path (= expand-file-name raw-path home))))
=C2=A0=3D=3D=3D=3D=3D

This adds the root and link instead of having the root be = a subset of link (hope that makes sense).

With tha= t, here is the updated MEW:

=3D=3D=3D=3D=3D
<= div>
#+TITLE: ox-html root dir
#+OPTIONS: toc:nil
#= +STARTUP: inlineimages
#+HTML_LINK_ROOT: /tmp/site/static/
<= div>
An =3Dimage.png=3D exists at =3D/tmp/site/static/images/= image.png=3D.

* TODO [1/2] This is how the image l= inks should have worked with the link root already specified
[[/i= mages/image.png]]
- [X] The =3DHTML_LINK_ROOT=3D should to append= ed to the front of the above link if
=C2=A0 that concatenated pat= h is a valid one.
- [ ] Would also like =3DC-x C-o=3D, inline ima= ge display, etc. to work.
=C2=A0 - So a thought.. should the link= root specification be made exporter
=C2=A0 agnostic?
=
=3D=3D=3D=3D=3D
--
<= div class=3D"gmail_signature" data-smartmail=3D"gmail_signature">

Kaushal Modi

--001a1141123042f4d30553fd7e2d--