emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Handling custom link types for html export in v 9.0 - Replacement for deprecated `org-add-link-type`?
@ 2017-04-17 18:52 Milan Zimmermann
  2017-04-18 14:00 ` John Kitchin
  0 siblings, 1 reply; 4+ messages in thread
From: Milan Zimmermann @ 2017-04-17 18:52 UTC (permalink / raw)
  To: emacs-orgmode

Hi:

I have a question about how to define custom link type, which before
9.0 used the (9.0) deprecated  `org-add-link-type`.

1. Let me first provide the context:

There is often a need to generate, for org links export/publish to
Html, elements where img src URL starts with a slash, like this

<img src="/images/a.jpg" >

The only way that was possible before v9, for this to be exported from
a link such as

[[/images/a.jgp]]

was to use a method described in

http://stackoverflow.com/questions/14684263/how-to-org-mode-image-absolute-path-of-export-html

- Basically, the solution described there is

a) define a custom link type such as "img"
b) in org,  use [[img:images/a.jpg]]
c) define two functions handling the img link in org and on
export/publish, and call (org-add-link-type "img"
'org-custom-link-img-follow 'org-custom-link-img-export)

2. The problem and question

In org 9.0, we get `org-add-link-type ... This function is obsolete
since Org 9.0 use `org-link-set-parameters' instead.

My problem is I have no idea how to, in a practical sense, use
`org-link-set-parameters` to define a custom link type "img" and
handle it's image handling in both org buffer and Html publish.

My question is, are there any links and examples how one would do the
above in 9.0?

Thanks
Milan

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

* Re: Handling custom link types for html export in v 9.0 - Replacement for deprecated `org-add-link-type`?
  2017-04-17 18:52 Handling custom link types for html export in v 9.0 - Replacement for deprecated `org-add-link-type`? Milan Zimmermann
@ 2017-04-18 14:00 ` John Kitchin
  2017-04-19  2:50   ` Milan Zimmermann
  0 siblings, 1 reply; 4+ messages in thread
From: John Kitchin @ 2017-04-18 14:00 UTC (permalink / raw)
  To: Milan Zimmermann; +Cc: emacs-orgmode

You can find a many examples of the new link syntax here:
http://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/

You will probably be able to reuse much of your old code  and this:

(org-link-set-parameters
   "img"
   :follow (your-old-follow-code)
   :export (your-old-export-code))

Milan Zimmermann writes:

> Hi:
>
> I have a question about how to define custom link type, which before
> 9.0 used the (9.0) deprecated  `org-add-link-type`.
>
> 1. Let me first provide the context:
>
> There is often a need to generate, for org links export/publish to
> Html, elements where img src URL starts with a slash, like this
>
> <img src="/images/a.jpg" >
>
> The only way that was possible before v9, for this to be exported from
> a link such as
>
> [[/images/a.jgp]]
>
> was to use a method described in
>
> http://stackoverflow.com/questions/14684263/how-to-org-mode-image-absolute-path-of-export-html
>
> - Basically, the solution described there is
>
> a) define a custom link type such as "img"
> b) in org,  use [[img:images/a.jpg]]
> c) define two functions handling the img link in org and on
> export/publish, and call (org-add-link-type "img"
> 'org-custom-link-img-follow 'org-custom-link-img-export)
>
> 2. The problem and question
>
> In org 9.0, we get `org-add-link-type ... This function is obsolete
> since Org 9.0 use `org-link-set-parameters' instead.
>
> My problem is I have no idea how to, in a practical sense, use
> `org-link-set-parameters` to define a custom link type "img" and
> handle it's image handling in both org buffer and Html publish.
>
> My question is, are there any links and examples how one would do the
> above in 9.0?
>
> Thanks
> Milan


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: Handling custom link types for html export in v 9.0 - Replacement for deprecated `org-add-link-type`?
  2017-04-18 14:00 ` John Kitchin
@ 2017-04-19  2:50   ` Milan Zimmermann
  2017-04-19 11:10     ` John Kitchin
  0 siblings, 1 reply; 4+ messages in thread
From: Milan Zimmermann @ 2017-04-19  2:50 UTC (permalink / raw)
  To: emacs-orgmode

Great, thanks very much John.

As a minor note I had to make a slight change

(org-link-set-parameters
  "img"
  :follow 'org-custom-link-img-follow     ; my old code
  :export 'org-custom-link-img-export)  ; my old code

And then it works equivalent with the previous version in 8.

Thanks
Milan

PS

(There is another note which is for a new thread: both in 8 and 9,
while they export what I need, actually do not display the image in
org buffer. The reason seem to be the  org-display-inline-images is
only looking for the "file" link but I need to debug that first)


On Tue, Apr 18, 2017 at 9:00 AM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> You can find a many examples of the new link syntax here:
> http://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/
>
> You will probably be able to reuse much of your old code  and this:
>
> (org-link-set-parameters
>    "img"
>    :follow (your-old-follow-code)
>    :export (your-old-export-code))
>
> Milan Zimmermann writes:
>
>> Hi:
>>
>> I have a question about how to define custom link type, which before
>> 9.0 used the (9.0) deprecated  `org-add-link-type`.
>>
>> 1. Let me first provide the context:
>>
>> There is often a need to generate, for org links export/publish to
>> Html, elements where img src URL starts with a slash, like this
>>
>> <img src="/images/a.jpg" >
>>
>> The only way that was possible before v9, for this to be exported from
>> a link such as
>>
>> [[/images/a.jgp]]
>>
>> was to use a method described in
>>
>> http://stackoverflow.com/questions/14684263/how-to-org-mode-image-absolute-path-of-export-html
>>
>> - Basically, the solution described there is
>>
>> a) define a custom link type such as "img"
>> b) in org,  use [[img:images/a.jpg]]
>> c) define two functions handling the img link in org and on
>> export/publish, and call (org-add-link-type "img"
>> 'org-custom-link-img-follow 'org-custom-link-img-export)
>>
>> 2. The problem and question
>>
>> In org 9.0, we get `org-add-link-type ... This function is obsolete
>> since Org 9.0 use `org-link-set-parameters' instead.
>>
>> My problem is I have no idea how to, in a practical sense, use
>> `org-link-set-parameters` to define a custom link type "img" and
>> handle it's image handling in both org buffer and Html publish.
>>
>> My question is, are there any links and examples how one would do the
>> above in 9.0?
>>
>> Thanks
>> Milan
>
>
> --
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu

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

* Re: Handling custom link types for html export in v 9.0 - Replacement for deprecated `org-add-link-type`?
  2017-04-19  2:50   ` Milan Zimmermann
@ 2017-04-19 11:10     ` John Kitchin
  0 siblings, 0 replies; 4+ messages in thread
From: John Kitchin @ 2017-04-19 11:10 UTC (permalink / raw)
  To: Milan Zimmermann; +Cc: emacs-orgmode

No problem. I usually use lambda functions there, but if you use
functions like you have the quoted form is right. Glad it was helpful!

Milan Zimmermann writes:

> Great, thanks very much John.
>
> As a minor note I had to make a slight change
>
> (org-link-set-parameters
>   "img"
>   :follow 'org-custom-link-img-follow     ; my old code
>   :export 'org-custom-link-img-export)  ; my old code
>
> And then it works equivalent with the previous version in 8.
>
> Thanks
> Milan
>
> PS
>
> (There is another note which is for a new thread: both in 8 and 9,
> while they export what I need, actually do not display the image in
> org buffer. The reason seem to be the  org-display-inline-images is
> only looking for the "file" link but I need to debug that first)
>
>
> On Tue, Apr 18, 2017 at 9:00 AM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
>> You can find a many examples of the new link syntax here:
>> http://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/
>>
>> You will probably be able to reuse much of your old code  and this:
>>
>> (org-link-set-parameters
>>    "img"
>>    :follow (your-old-follow-code)
>>    :export (your-old-export-code))
>>
>> Milan Zimmermann writes:
>>
>>> Hi:
>>>
>>> I have a question about how to define custom link type, which before
>>> 9.0 used the (9.0) deprecated  `org-add-link-type`.
>>>
>>> 1. Let me first provide the context:
>>>
>>> There is often a need to generate, for org links export/publish to
>>> Html, elements where img src URL starts with a slash, like this
>>>
>>> <img src="/images/a.jpg" >
>>>
>>> The only way that was possible before v9, for this to be exported from
>>> a link such as
>>>
>>> [[/images/a.jgp]]
>>>
>>> was to use a method described in
>>>
>>> http://stackoverflow.com/questions/14684263/how-to-org-mode-image-absolute-path-of-export-html
>>>
>>> - Basically, the solution described there is
>>>
>>> a) define a custom link type such as "img"
>>> b) in org,  use [[img:images/a.jpg]]
>>> c) define two functions handling the img link in org and on
>>> export/publish, and call (org-add-link-type "img"
>>> 'org-custom-link-img-follow 'org-custom-link-img-export)
>>>
>>> 2. The problem and question
>>>
>>> In org 9.0, we get `org-add-link-type ... This function is obsolete
>>> since Org 9.0 use `org-link-set-parameters' instead.
>>>
>>> My problem is I have no idea how to, in a practical sense, use
>>> `org-link-set-parameters` to define a custom link type "img" and
>>> handle it's image handling in both org buffer and Html publish.
>>>
>>> My question is, are there any links and examples how one would do the
>>> above in 9.0?
>>>
>>> Thanks
>>> Milan
>>
>>
>> --
>> Professor John Kitchin
>> Doherty Hall A207F
>> Department of Chemical Engineering
>> Carnegie Mellon University
>> Pittsburgh, PA 15213
>> 412-268-7803
>> @johnkitchin
>> http://kitchingroup.cheme.cmu.edu


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-17 18:52 Handling custom link types for html export in v 9.0 - Replacement for deprecated `org-add-link-type`? Milan Zimmermann
2017-04-18 14:00 ` John Kitchin
2017-04-19  2:50   ` Milan Zimmermann
2017-04-19 11:10     ` John Kitchin

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