all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help resolving CUSTOM_ID based links that point to outside current subtree scope
@ 2017-07-28 19:17 Kaushal Modi
  2017-07-28 19:19 ` Kaushal Modi
  0 siblings, 1 reply; 5+ messages in thread
From: Kaushal Modi @ 2017-07-28 19:17 UTC (permalink / raw)
  To: emacs-org list

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

Hello,

Is there a way to make org-export-resolve-id-link look for link resolution
outside the current scope?

I just threw in a (save-restriction (widen) ..) inside
org-export-resolve-id-link, and that of course did not work (and thus this
email).

Below is a little example:

* Link source
:PROPERTIES:
:EXPORT_FILE_NAME: link-source
:END:
- Link to [[#link-dest][Link dest]]
** Link dest
:PROPERTIES:
:EXPORT_FILE_NAME: link-dest
:CUSTOM_ID: link-dest
:END:

- I would like to export just the "Link source" subtree (let's say C-c C-e
C-s t A), and have the link resolve to the "link-dest" CUSTOM_ID.
- To put this the other way, I want to export just the subtree, but look at
the whole buffer for link resolution.

I know that does not make sense, but I need that for the Hugo exporter
backend.

Application: I have one subtree (Hugo post) containing a CUSTOM_ID based
internal link to some other subtree (Hugo post), and I want to retain the
link reference. Hugo would then figure out the rest.

What function could I advice and with what to make this happen?

Thanks.
-- 

Kaushal Modi

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

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

* Re: Help resolving CUSTOM_ID based links that point to outside current subtree scope
  2017-07-28 19:17 Help resolving CUSTOM_ID based links that point to outside current subtree scope Kaushal Modi
@ 2017-07-28 19:19 ` Kaushal Modi
  2017-08-01  8:25   ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Kaushal Modi @ 2017-07-28 19:19 UTC (permalink / raw)
  To: emacs-org list

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

Ah! I made a typo in the example above; here's the corrected one:

* Link source
:PROPERTIES:
:EXPORT_FILE_NAME: link-source
:END:
- Link to [[#link-dest][Link dest]]
* Link dest
:PROPERTIES:
:EXPORT_FILE_NAME: link-dest
:CUSTOM_ID: link-dest
:END:

("Link source" and "Link dest" subtrees are at the same level. So exporting
just "Link source" subtree does not 'see' the "Link dest" subtree.)

On Fri, Jul 28, 2017 at 3:17 PM Kaushal Modi <kaushal.modi@gmail.com> wrote:

> Hello,
>
> Is there a way to make org-export-resolve-id-link look for link resolution
> outside the current scope?
>
> I just threw in a (save-restriction (widen) ..) inside
> org-export-resolve-id-link, and that of course did not work (and thus this
> email).
>
> Below is a little example:
>
> * Link source
> :PROPERTIES:
> :EXPORT_FILE_NAME: link-source
> :END:
> - Link to [[#link-dest][Link dest]]
> ** Link dest
> :PROPERTIES:
> :EXPORT_FILE_NAME: link-dest
> :CUSTOM_ID: link-dest
> :END:
>
> - I would like to export just the "Link source" subtree (let's say C-c C-e
> C-s t A), and have the link resolve to the "link-dest" CUSTOM_ID.
> - To put this the other way, I want to export just the subtree, but look
> at the whole buffer for link resolution.
>
> I know that does not make sense, but I need that for the Hugo exporter
> backend.
>
> Application: I have one subtree (Hugo post) containing a CUSTOM_ID based
> internal link to some other subtree (Hugo post), and I want to retain the
> link reference. Hugo would then figure out the rest.
>
> What function could I advice and with what to make this happen?
>
> Thanks.
> --
>
> Kaushal Modi
>
-- 

Kaushal Modi

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

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

* Re: Help resolving CUSTOM_ID based links that point to outside current subtree scope
  2017-07-28 19:19 ` Kaushal Modi
@ 2017-08-01  8:25   ` Nicolas Goaziou
  2017-08-01 11:08     ` Kaushal Modi
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2017-08-01  8:25 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Ah! I made a typo in the example above; here's the corrected one:
>
> * Link source
> :PROPERTIES:
> :EXPORT_FILE_NAME: link-source
> :END:
> - Link to [[#link-dest][Link dest]]
> * Link dest
> :PROPERTIES:
> :EXPORT_FILE_NAME: link-dest
> :CUSTOM_ID: link-dest
> :END:
>
> ("Link source" and "Link dest" subtrees are at the same level. So exporting
> just "Link source" subtree does not 'see' the "Link dest" subtree.)

I guess you could write a function that changes custom ID links into
external links prior to export, e.g., within
`org-export-before-parsing-hook'.

Regards,

-- 
Nicolas Goaziou

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

* Re: Help resolving CUSTOM_ID based links that point to outside current subtree scope
  2017-08-01  8:25   ` Nicolas Goaziou
@ 2017-08-01 11:08     ` Kaushal Modi
  2017-08-01 16:46       ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Kaushal Modi @ 2017-08-01 11:08 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

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

On Tue, Aug 1, 2017, 4:26 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

>
> I guess you could write a function that changes custom ID links into
> external links prior to export, e.g., within
> `org-export-before-parsing-hook'.
>


If I understand correctly, it would mean replacing "[[#link]]" with
"[[./current-file.org::#link]]"? (I haven't yet verified if that
#+INCLUDE-like syntax works for links too.)

Also, I am working on implementing this in an exporter backend. So what
would be the canonical way to do that in ox-foo.el?

Thanks.

> --

Kaushal Modi

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

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

* Re: Help resolving CUSTOM_ID based links that point to outside current subtree scope
  2017-08-01 11:08     ` Kaushal Modi
@ 2017-08-01 16:46       ` Nicolas Goaziou
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Goaziou @ 2017-08-01 16:46 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Also, I am working on implementing this in an exporter backend. So what
> would be the canonical way to do that in ox-foo.el?

I think I would do something like this: in a parse tree filter, find
every custom ID link then expand current buffer, find real destination,
and replace the original ID link with an external link generated from
the aforementioned destination.

Regards,

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

end of thread, other threads:[~2017-08-01 16:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-28 19:17 Help resolving CUSTOM_ID based links that point to outside current subtree scope Kaushal Modi
2017-07-28 19:19 ` Kaushal Modi
2017-08-01  8:25   ` Nicolas Goaziou
2017-08-01 11:08     ` Kaushal Modi
2017-08-01 16:46       ` Nicolas Goaziou

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.