emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>,
	Tim Cross <theophilusx@gmail.com>
Cc: Carsten Dominik <dominik@uva.nl>, emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: why prepend "file://" to abs paths in html output?
Date: Mon, 10 Jul 2017 12:53:10 +0000	[thread overview]
Message-ID: <CAFyQvY0qztmUUmQjnPdk0tFA4vT0DP9Q-SrOOacfLYNykRKekg@mail.gmail.com> (raw)
In-Reply-To: <877ezh51ns.fsf@nicolasgoaziou.fr>

[-- Attachment #1: Type: text/plain, Size: 3676 bytes --]

Hello,


On Sun, Jul 9, 2017, 6:45 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

>
> The following patch implements `org-html-root', which allows to export
> file links as root-relative URL.


Can you please attach the patch?

I'm

 not sure the docstring is clear
> enough, tho.
>

Also, HTML publishing process always bind the above to publishing
> directory, without user intervention.
>

Matt and I are working on an exporter backend for Hugo, ox-hugo. We are
exporting Org to a flavor of Markdown compatible with Hugo. The HTML
exporter has some contribution in this exporter.

If a link is "/foo/bar" in the Markdown file, Hugo assumes "foo" to be
present in the "static/" dir in the site root. So the Markdown link auto
expands to "example.org/static/foo/bar".

But if the link was "/foo/bar" in the Org file to begin, with it would
become "file:///foo/bar" in Markdown (as it is a derivation of ox-md).
Though, we got around that by overriding the org-md-link function in
ox-hugo.

The complication arose when we needed to support "#+ATTR_HTML: :class
something" above figure links. We then needed to let the html link exporter
take up the link translation job instead of having ox-hugo do that directly
(it is OK to have HTML snippets in Markdown). And thus this request.

So, basically, upon exporting the following document to HTML:
>
>   #+html_link_root: /tmp/
>   [[/tmp/unicorn.jpg]]
>
> the link becomes
>
>   <img src="/unicorn.jpg" alt="unicorn.jpg" />
>

Based on the example, that patch might work!

=====

Reply to an earlier email:

On Sat, Jul 8, 2017 at 3:14 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Carsten Dominik <dominik@uva.nl> writes:
>
> > I think it can be useful to write file: in the org-mode file, to make a
> > clear distinction from internal links.  But once it is clear that
> something
> > is a link to a file, I guess you are right  that it might not be needed
> in
> > HTML.  We will see what breaks.....
>
> Thinking about it, we should probably not remove the "file://" prefix.
>

It depends.. if people are using Org files exported as HTML to open
referenced files in their browser (though that would work only if they open
those HTML pages only on that machine). But at least in one browser
(Firefox), I noticed that the browser auto-added the "file://" prefix if
user tried to access "/static/images/unicorn.jpg" directly from the address
bar.

I cannot think of any situation where [[/absolute/path/to/file]] would
> match something like "<img src="/absolute/path/to/file"/>", because "/"
> never matches web root directory.
>

As mentioned above, one example is Hugo, which auto-interprets the presence
of absolute links in the Markdown files (whether they are of Markdown or
HTML style).

Note that that "file:///static/images/unicorn.jpg" is not useful either,
> but at least it is logical.
>

 I can see the benefit if a browser does not support auto-detection of
local links. But if the patch works, all should be good :)

The only situation where we might do something is during publishing,
> when we know what web root directory – i.e., base directory – is. In
> that case, we could replace absolute file names starting with web root
> dir as root-relative URL.
>

In our case, we are delegating that step to Hugo. So Org does the job of
content translation from Org to Markdown (plus inline HTML code for
figures, etc) "as it is", and Hugo does the job of HTML, RSS, etc.
generation, content management (what goes in what directory), link
resolution, etc.

> --

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 6331 bytes --]

  reply	other threads:[~2017-07-10 12:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-08  0:38 why prepend "file://" to abs paths in html output? Matt Price
2017-07-08 10:33 ` Nicolas Goaziou
2017-07-08 12:37   ` Kaushal Modi
2017-07-08 14:08     ` Nicolas Goaziou
2017-07-08 14:19       ` Carsten Dominik
2017-07-08 19:13         ` Nicolas Goaziou
2017-07-08 23:37           ` Tim Cross
2017-07-09 10:45             ` Nicolas Goaziou
2017-07-10 12:53               ` Kaushal Modi [this message]
2017-07-10 13:31                 ` Nicolas Goaziou
2017-07-10 13:58               ` Brett Viren
2017-07-10 19:54                 ` Kaushal Modi
2017-07-10 21:44                   ` Kaushal Modi
2017-07-13 12:39                   ` Nicolas Goaziou
2017-07-13 12:50                     ` Kaushal Modi
2017-07-13 12:55                       ` Nicolas Goaziou
2017-07-13 13:01                         ` Kaushal Modi
2017-07-13 13:14                           ` Nicolas Goaziou
2017-07-13 12:46                 ` Nicolas Goaziou
2017-07-10 22:12               ` Tim Cross

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=CAFyQvY0qztmUUmQjnPdk0tFA4vT0DP9Q-SrOOacfLYNykRKekg@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=dominik@uva.nl \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --cc=theophilusx@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).