* Use id property as anchor in the Table of Contents
@ 2011-09-07 21:07 Pere Quintana Seguí
2011-09-08 0:34 ` Bernt Hansen
0 siblings, 1 reply; 8+ messages in thread
From: Pere Quintana Seguí @ 2011-09-07 21:07 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 947 bytes --]
Hi,
I'm using Org-mode to publish my website. One of my site's pages has a lot
of sections and the number of sections is increasing rapidly.
My problem is that the HTML exporter, in the Table of Contents, is using the
section numbers as anchors. As the section numbers change with time, I can't
get stable links across versions of the document.
As many of the sections (headings) have id properties, I'd like the HTML
exporter to use them as anchor for the Table of Contents, when available.
Is this possible? I didn't find an answer in the manual.
As an example. This is the document I'm working on:
http://pere.quintanasegui.com/diccionari-tecnologia.html#sec-2-78
As you can see, section 2.78, called RSS, has the anchor sec-2-78. If the
anchor was its id "04E3903E-EAF1-499F-98CD-9E3E4BA0806A", the link would
remain the same in the future. I don't mind if the URL is not human
readable. Sec-2-78 isn't human readable too.
Thanks
Pere
[-- Attachment #2: Type: text/html, Size: 1344 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Use id property as anchor in the Table of Contents
2011-09-07 21:07 Use id property as anchor in the Table of Contents Pere Quintana Seguí
@ 2011-09-08 0:34 ` Bernt Hansen
2011-09-08 10:53 ` Pere Quintana Seguí
0 siblings, 1 reply; 8+ messages in thread
From: Bernt Hansen @ 2011-09-08 0:34 UTC (permalink / raw)
To: pquintana; +Cc: emacs-orgmode
Pere Quintana Seguí <pquintana@obsebre.es> writes:
> Hi,
>
> I'm using Org-mode to publish my website. One of my site's pages has
> a lot of sections and the number of sections is increasing rapidly.
>
> My problem is that the HTML exporter, in the Table of Contents, is
> using the section numbers as anchors. As the section numbers change
> with time, I can't get stable links across versions of the document.
>
> As many of the sections (headings) have id properties, I'd like the
> HTML exporter to use them as anchor for the Table of Contents, when
> available.
>
> Is this possible? I didn't find an answer in the manual.
>
> As an example. This is the document I'm working on:
> http://pere.quintanasegui.com/diccionari-tecnologia.html#sec-2-78
>
> As you can see, section 2.78, called RSS, has the anchor sec-2-78. If
> the anchor was its id "04E3903E-EAF1-499F-98CD-9E3E4BA0806A", the
> link would remain the same in the future. I don't mind if the URL is
> not human readable. Sec-2-78 isn't human readable too.
Hi Pere,
You can manually provide CUSTOM_ID properties. These ids are used in
the TOC.
e.g.
* Reminders
:PROPERTIES:
:CUSTOM_ID: Reminders
:END:
for
http://doc.norang.ca/org-mode.html#Reminders
I don't know if there is a way to use the ID property automatically.
Regards,
Bernt
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Use id property as anchor in the Table of Contents
2011-09-08 0:34 ` Bernt Hansen
@ 2011-09-08 10:53 ` Pere Quintana Seguí
2011-09-13 10:05 ` Olaf Dietsche
0 siblings, 1 reply; 8+ messages in thread
From: Pere Quintana Seguí @ 2011-09-08 10:53 UTC (permalink / raw)
To: Bernt Hansen; +Cc: emacs-orgmode
2011/9/8 Bernt Hansen <bernt@norang.ca>
>
> Pere Quintana Seguí <pquintana@obsebre.es> writes:
>
> > Hi,
> >
> > I'm using Org-mode to publish my website. One of my site's pages has
> > a lot of sections and the number of sections is increasing rapidly.
> >
> > My problem is that the HTML exporter, in the Table of Contents, is
> > using the section numbers as anchors. As the section numbers change
> > with time, I can't get stable links across versions of the document.
> >
> > As many of the sections (headings) have id properties, I'd like the
> > HTML exporter to use them as anchor for the Table of Contents, when
> > available.
> >
> > Is this possible? I didn't find an answer in the manual.
> >
> > As an example. This is the document I'm working on:
> > http://pere.quintanasegui.com/diccionari-tecnologia.html#sec-2-78
> >
> > As you can see, section 2.78, called RSS, has the anchor sec-2-78. If
> > the anchor was its id "04E3903E-EAF1-499F-98CD-9E3E4BA0806A", the
> > link would remain the same in the future. I don't mind if the URL is
> > not human readable. Sec-2-78 isn't human readable too.
>
> Hi Pere,
>
> You can manually provide CUSTOM_ID properties. These ids are used in
> the TOC.
>
> e.g.
>
> * Reminders
> :PROPERTIES:
> :CUSTOM_ID: Reminders
> :END:
>
> for
>
> http://doc.norang.ca/org-mode.html#Reminders
OK, thanks for the tip. That's an option, but unfortunately it is not
automatic.
> I don't know if there is a way to use the ID property automatically.
Unfortunately I don't know lisp, so I can't modify org-mode to provide
this feature :'(
If anyone is willing, I would be very grateful.
Thanks,
Pere
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Use id property as anchor in the Table of Contents
2011-09-08 10:53 ` Pere Quintana Seguí
@ 2011-09-13 10:05 ` Olaf Dietsche
2011-09-13 14:53 ` Pere Quintana Seguí
2012-04-20 11:51 ` Bastien
0 siblings, 2 replies; 8+ messages in thread
From: Olaf Dietsche @ 2011-09-13 10:05 UTC (permalink / raw)
To: pquintana; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2025 bytes --]
Pere Quintana Seguí <pquintana@obsebre.es> writes:
> 2011/9/8 Bernt Hansen <bernt@norang.ca>
>>
>> Pere Quintana Seguí <pquintana@obsebre.es> writes:
>>
>> > Hi,
>> >
>> > I'm using Org-mode to publish my website. One of my site's pages has
>> > a lot of sections and the number of sections is increasing rapidly.
>> >
>> > My problem is that the HTML exporter, in the Table of Contents, is
>> > using the section numbers as anchors. As the section numbers change
>> > with time, I can't get stable links across versions of the document.
>> >
>> > As many of the sections (headings) have id properties, I'd like the
>> > HTML exporter to use them as anchor for the Table of Contents, when
>> > available.
>> >
>> > Is this possible? I didn't find an answer in the manual.
>> >
>> > As an example. This is the document I'm working on:
>> > http://pere.quintanasegui.com/diccionari-tecnologia.html#sec-2-78
>> >
>> > As you can see, section 2.78, called RSS, has the anchor sec-2-78. If
>> > the anchor was its id "04E3903E-EAF1-499F-98CD-9E3E4BA0806A", the
>> > link would remain the same in the future. I don't mind if the URL is
>> > not human readable. Sec-2-78 isn't human readable too.
>>
>> Hi Pere,
>>
>> You can manually provide CUSTOM_ID properties. These ids are used in
>> the TOC.
>>
>> e.g.
>>
>> * Reminders
>> :PROPERTIES:
>> :CUSTOM_ID: Reminders
>> :END:
>>
>> for
>>
>> http://doc.norang.ca/org-mode.html#Reminders
>
> OK, thanks for the tip. That's an option, but unfortunately it is not
> automatic.
>
>> I don't know if there is a way to use the ID property automatically.
>
> Unfortunately I don't know lisp, so I can't modify org-mode to provide
> this feature :'(
>
> If anyone is willing, I would be very grateful.
You might try this *untested* patch. It is against git master.
How did you create ID properties for all entries? Have you exported your
org-files to icalendar?
And please, don't forget to backup your files!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Use ID property as target --]
[-- Type: text/x-diff, Size: 1103 bytes --]
diff --git a/lisp/org-html.el b/lisp/org-html.el
index fde563b..806bbb9 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1438,8 +1438,9 @@ lang=\"%s\" xml:lang=\"%s\">
(replace-regexp-in-string
"\\." "-" (format "sec-%s" snumber)))
(setq href (org-solidify-link-text
- (or (cdr (assoc href
- org-export-preferred-target-alist)) href)))
+ (or (cdr (assoc href org-export-preferred-target-alist))
+ (cdr (assoc href org-export-id-target-alist))
+ href)))
(push
(format
(if todo
@@ -2413,7 +2414,8 @@ When TITLE is nil, just close all open levels."
(assoc target org-export-target-aliases)))
(extra-class (and title (org-get-text-property-any 0 'html-container-class title)))
(preferred (and target
- (cdr (assoc target org-export-preferred-target-alist))))
+ (or (cdr (assoc target org-export-preferred-target-alist))
+ (cdr (assoc target org-export-id-target-alist)))))
(l org-level-max)
(num (plist-get opt-plist :section-numbers))
snumber snu href suffix)
[-- Attachment #3: Type: text/plain, Size: 15 bytes --]
Regards, Olaf
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Use id property as anchor in the Table of Contents
2011-09-13 10:05 ` Olaf Dietsche
@ 2011-09-13 14:53 ` Pere Quintana Seguí
2011-09-15 9:18 ` Olaf Dietsche
2012-04-20 11:51 ` Bastien
1 sibling, 1 reply; 8+ messages in thread
From: Pere Quintana Seguí @ 2011-09-13 14:53 UTC (permalink / raw)
To: Olaf Dietsche; +Cc: emacs-orgmode
2011/9/13 Olaf Dietsche <olaf+list.orgmode@olafdietsche.de>:
> You might try this *untested* patch. It is against git master.
:D Thanks!!!
> How did you create ID properties for all entries? Have you exported your
> org-files to icalendar?
Most of them have ID properties because I often link them internally.
When I create the link with C-c l, org adds the id.
For those that do not have ID, I'll create them manually with
org-id-get-create. With a keyboard macro this will be fast.
> And please, don't forget to backup your files!
Of course! Fortunately I version control my ~/org folder with Bazaar.
With this patch, what happens if there is no id in a heading, does it
create it automatically?
At work I'm using stable versions of Org-mode. This weekend I'll try
the git version at home and test your patch.
Thanks
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Use id property as anchor in the Table of Contents
2011-09-13 14:53 ` Pere Quintana Seguí
@ 2011-09-15 9:18 ` Olaf Dietsche
2011-09-15 11:52 ` Pere Quintana Seguí
0 siblings, 1 reply; 8+ messages in thread
From: Olaf Dietsche @ 2011-09-15 9:18 UTC (permalink / raw)
To: pquintana; +Cc: emacs-orgmode
Pere Quintana Seguí <pquintana@obsebre.es> writes:
> 2011/9/13 Olaf Dietsche <olaf+list.orgmode@olafdietsche.de>:
>> How did you create ID properties for all entries? Have you exported your
>> org-files to icalendar?
>
> Most of them have ID properties because I often link them internally.
> When I create the link with C-c l, org adds the id.
>
> For those that do not have ID, I'll create them manually with
> org-id-get-create. With a keyboard macro this will be fast.
Ok, thanks for this explanation.
> With this patch, what happens if there is no id in a heading, does it
> create it automatically?
It is supposed to use the CUSTOM_ID, if set. Next, it tries the ID
property. At last, it falls back to "sec-...".
> At work I'm using stable versions of Org-mode. This weekend I'll try
> the git version at home and test your patch.
Regards, Olaf
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Use id property as anchor in the Table of Contents
2011-09-13 10:05 ` Olaf Dietsche
2011-09-13 14:53 ` Pere Quintana Seguí
@ 2012-04-20 11:51 ` Bastien
1 sibling, 0 replies; 8+ messages in thread
From: Bastien @ 2012-04-20 11:51 UTC (permalink / raw)
To: Olaf Dietsche; +Cc: emacs-orgmode, pquintana
Hi Olaf,
Olaf Dietsche <olaf+list.orgmode@olafdietsche.de> writes:
> You might try this *untested* patch. It is against git master.
Thanks a lot for this patch. I won't apply tho, because it might break
the current setup of users who use :ID: and expect "sec-" to be the
prefix for the anchor.
We will try to handle Pere's request when integrating the new HTML
exporter.
Best,
--
Bastien
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-04-20 11:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-07 21:07 Use id property as anchor in the Table of Contents Pere Quintana Seguí
2011-09-08 0:34 ` Bernt Hansen
2011-09-08 10:53 ` Pere Quintana Seguí
2011-09-13 10:05 ` Olaf Dietsche
2011-09-13 14:53 ` Pere Quintana Seguí
2011-09-15 9:18 ` Olaf Dietsche
2011-09-15 11:52 ` Pere Quintana Seguí
2012-04-20 11:51 ` Bastien
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).