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