emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* new exporter: link abbrev
@ 2012-12-03 15:20 Michael Brand
  2012-12-04 11:40 ` Jambunathan K
  2012-12-05 21:05 ` Nicolas Goaziou
  0 siblings, 2 replies; 7+ messages in thread
From: Michael Brand @ 2012-12-03 15:20 UTC (permalink / raw)
  To: Org Mode

Hi all

I think the new exporter should still expand link abbreviations also
when in the heading and for all backends. Example with html link on
today’s release_7.9.2-646-g664217:

- Org file:
  #+LINK: orgmode http://www.orgmode.org/
  * Org Mode doc [[orgmode:#docs]]

- export to html:
  - old exporter expands link:
    <h2 id="sec-1"><span class="section-number-2">1</span> Org Mode doc
    <a href="http://www.orgmode.org/#docs">http://www.orgmode.org/#docs</a></h2>
  - new exporter leaves link abbreviated:
    <h2 id="sec-1"><span class="section-number-2">1</span> Org Mode doc
    <i>orgmode:#docs</i></h2>

- export to ascii:
  - old exporter expands link:
    1 Org Mode doc [http://www.orgmode.org/#docs]
  - new exporter omits link:
    1 Org Mode doc

Michael

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: new exporter: link abbrev
  2012-12-03 15:20 new exporter: link abbrev Michael Brand
@ 2012-12-04 11:40 ` Jambunathan K
  2012-12-04 14:59   ` Bastien
  2012-12-05 21:05 ` Nicolas Goaziou
  1 sibling, 1 reply; 7+ messages in thread
From: Jambunathan K @ 2012-12-04 11:40 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode


I would like to hear Nicolas' views before someone gets too excited to
put in a change.

> Hi all
>
> I think the new exporter should still expand link abbreviations also
> when in the heading and for all backends. Example with html link on
> today’s release_7.9.2-646-g664217:
>
> - Org file:
>
>   #+LINK: orgmode http://www.orgmode.org/
>   * Org Mode doc [[orgmode:#docs]]
>
>
> - export to html:
>   - old exporter expands link:
>     <h2 id="sec-1"><span class="section-number-2">1</span> Org Mode doc
>     <a href="http://www.orgmode.org/#docs">http://www.orgmode.org/#docs</a></h2>
>   - new exporter leaves link abbreviated:
>     <h2 id="sec-1"><span class="section-number-2">1</span> Org Mode doc
>     <i>orgmode:#docs</i></h2>
>
> - export to ascii:
>   - old exporter expands link:
>     1 Org Mode doc [http://www.orgmode.org/#docs]
>   - new exporter omits link:
>     1 Org Mode doc
>
> Michael
>
>

-- 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: new exporter: link abbrev
  2012-12-04 11:40 ` Jambunathan K
@ 2012-12-04 14:59   ` Bastien
  0 siblings, 0 replies; 7+ messages in thread
From: Bastien @ 2012-12-04 14:59 UTC (permalink / raw)
  To: Jambunathan K; +Cc: Michael Brand, Org Mode

Hi Michael,

Jambunathan K <kjambunathan@gmail.com> writes:

> I would like to hear Nicolas' views before someone gets too excited to
> put in a change.

I do agree with Jambunathan.  

But let's keep this option in mind anyway.

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: new exporter: link abbrev
  2012-12-03 15:20 new exporter: link abbrev Michael Brand
  2012-12-04 11:40 ` Jambunathan K
@ 2012-12-05 21:05 ` Nicolas Goaziou
  2012-12-06 15:13   ` Michael Brand
  1 sibling, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2012-12-05 21:05 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode

Hello,

Michael Brand <michael.ch.brand@gmail.com> writes:

> I think the new exporter should still expand link abbreviations also
> when in the heading and for all backends. Example with html link on
> today’s release_7.9.2-646-g664217:
>
> - Org file:
>   #+LINK: orgmode http://www.orgmode.org/
>   * Org Mode doc [[orgmode:#docs]]
>
> - export to html:
>   - old exporter expands link:
>     <h2 id="sec-1"><span class="section-number-2">1</span> Org Mode doc
>     <a href="http://www.orgmode.org/#docs">http://www.orgmode.org/#docs</a></h2>
>   - new exporter leaves link abbreviated:
>     <h2 id="sec-1"><span class="section-number-2">1</span> Org Mode doc
>     <i>orgmode:#docs</i></h2>
>
> - export to ascii:
>   - old exporter expands link:
>     1 Org Mode doc [http://www.orgmode.org/#docs]
>   - new exporter omits link:
>     1 Org Mode doc

There are two things going on here. 

The first one, which is minor, is that e-ascii back-end currently
doesn't handle correctly translated links anywhere. This is easy to fix.

The second one is a more difficult problem. Org Elements usually
translates links on the fly when parsing them: `org-element-link-parser'
calls `org-translate-link'. This function requires
`org-link-abbrev-alist' and `org-link-abbrev-alist-local' variables to
be set properly, the second one being a local variable.

Unfortunately, parsing of secondary strings (in particular headline
titles or inline footnote definitions) happens in a temporary buffer,
where no local variable is set. There `org-link-abbrev-alist-local' is
nil, no matter what your #+LINK: keyword says, and link translation
can't happen.

Also, local variables cannot be send to the temporary buffer, because
secondary string parsing can sometimes happen when the original buffer
isn't supposed to exist, that is during export (when the parse tree is
the only trusted data).

A possible solution would be to move link translation from
org-element.el to org-export.el. But that would require to explicitly
call a translator function on links, which would be an additional task
for back-end developers. Also, `org-element-context' would not return
anymore the real path of the abbreviated link, only its raw path.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: new exporter: link abbrev
  2012-12-05 21:05 ` Nicolas Goaziou
@ 2012-12-06 15:13   ` Michael Brand
  2012-12-18 21:21     ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Brand @ 2012-12-06 15:13 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

Hi Nicolas

On Wed, Dec 5, 2012 at 10:05 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> The second one is a more difficult problem. Org Elements usually
> translates links on the fly when parsing them: `org-element-link-parser'
> calls `org-translate-link'. This function requires
> `org-link-abbrev-alist' and `org-link-abbrev-alist-local' variables to
> be set properly, the second one being a local variable.
>
> Unfortunately, parsing of secondary strings (in particular headline
> titles or inline footnote definitions) happens in a temporary buffer,
> where no local variable is set. There `org-link-abbrev-alist-local' is
> nil, no matter what your #+LINK: keyword says, and link translation
> can't happen.
>
> Also, local variables cannot be send to the temporary buffer, because
> secondary string parsing can sometimes happen when the original buffer
> isn't supposed to exist, that is during export (when the parse tree is
> the only trusted data).

Thank you for the explanations.

> A possible solution would be to move link translation from
> org-element.el to org-export.el. But that would require to explicitly
> call a translator function on links, which would be an additional task
> for back-end developers. Also, `org-element-context' would not return
> anymore the real path of the abbreviated link, only its raw path.

I would like to not burden back-end developers with this.

In the meantime I found out that I can simply add
org-export-normalize-links to org-export-before-processing-hook and it
seems to do what I expect. But this is probably not to be included in
Org core because the (hopefully at least only basic) pre-parsing of
org-export-normalize-links undermines the later parsing of
org-elements. In case org-export-normalize-links would survive the old
exporter (I fear it will not) the workaround of hooking would do it
for me.

Michael

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: new exporter: link abbrev
  2012-12-06 15:13   ` Michael Brand
@ 2012-12-18 21:21     ` Nicolas Goaziou
  2012-12-19 11:10       ` Michael Brand
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2012-12-18 21:21 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode

Michael Brand <michael.ch.brand@gmail.com> writes:

> In the meantime I found out that I can simply add
> org-export-normalize-links to org-export-before-processing-hook and it
> seems to do what I expect. But this is probably not to be included in
> Org core because the (hopefully at least only basic) pre-parsing of
> org-export-normalize-links undermines the later parsing of
> org-elements. In case org-export-normalize-links would survive the old
> exporter (I fear it will not) the workaround of hooking would do it
> for me.

The problem should now be fixed without using any trick (and no,
`org-export-normalize-links' will not survive the old exporter).


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: new exporter: link abbrev
  2012-12-18 21:21     ` Nicolas Goaziou
@ 2012-12-19 11:10       ` Michael Brand
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Brand @ 2012-12-19 11:10 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

Hi Nicolas

On Tue, Dec 18, 2012 at 10:21 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> The problem should now be fixed without using any trick

It is, thank you.

> (and no,
> `org-export-normalize-links' will not survive the old exporter).

Thanks to your change above I like this cleanup.

Michael

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-12-19 11:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-03 15:20 new exporter: link abbrev Michael Brand
2012-12-04 11:40 ` Jambunathan K
2012-12-04 14:59   ` Bastien
2012-12-05 21:05 ` Nicolas Goaziou
2012-12-06 15:13   ` Michael Brand
2012-12-18 21:21     ` Nicolas Goaziou
2012-12-19 11:10       ` Michael Brand

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).