all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Timothy <tecosaur@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Tim Cross <theophilusx@gmail.com>,
	emacs-orgmode@gnu.org, Samuel Loury <konubinix@gmail.com>
Subject: Re: stability of toc links
Date: Mon, 03 May 2021 04:16:06 +0800	[thread overview]
Message-ID: <8735v4hoxl.fsf@gmail.com> (raw)
In-Reply-To: <875z019w0r.fsf@nicolasgoaziou.fr>


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Please note that those short answers did not help me much. So I did my
> homework and looked at your code. I didn't test it thoroughly, so I may
> be missing something.

It's a pity to hear that I wasn't able to suitably clarify things in my
reply. Thank you for being willing to investigate my implementation.

> Now, here's the elephant in the room: "puny.el" was included in Emacs
> 26.1. Org cannot make use of it yet.

Gah.

> Also, the bootstring algorithm, and yours, are very much
> English-centered, as can attest
> `org-reference-contraction-stripped-words'. I insisted on non-latin
> languages for a reason:
>
>        (org-reference-contraction "こんにちは") =>  "28j2a3ar1p-"
>
> or, for a not so long title
>
>   (org-reference-contraction "こんにちは コンニチハ") => "v8ttbvbva7si998jvba0bzb0m-"
>
> which is arguably worse than "org1234567".

Mmmm. This isn't great. I preferred the output of Unidecode (ASCII
transliteration) mentioned previously, but that doesn't look like it
could easily be used.

>>> references are guaranteed to be unique in the document;
>>
>> The suffixed number I mentioned ensures this.
>
> Unfortunately, because of them, you cannot guarantee stable links during
> export, much like random references.
>
> For example, if you first export
>
>   * Foo
>   bar
>
> and if you later modify your document like this
>
>   * Foo
>   baz
>   * Foo
>   bar
>
> your link will now point to the "baz" contents instead of "bar".
>
> As a side note, this the reason why I introduced randomness in
> references in the first place. We cannot reference first headline as
> "headline-1", second one as "headline-2", i.e., in a monotonic way,
> because we cannot assume their order is fixed.

From this I take it you'd rather a broken reference than an incorrect
one? I don't think there's any "good" solution here, just pick your
poison (and, no surprise, I prefer my way).

> More importantly, the above is not limited to headlines with the exact
> same title. Since your algorithm truncates output, this will happen in
> various, less obvious, situations.

While this is technically possible, I think it's worth noting that I
have never seen this in practice, and for reference I have documents
with hundreds of headings (250 in my config, for example).

>>> Also, header content is not stable enough: when you're linking to the
>>> custom ID, you may be able to change the title and yet preserve the
>>> link.
>>
>> Custom IDs still work, so I don't quite see the point here.
>
> How can you be sure?
>
> The point is that in some export back-ends, e.g., ASCII, you will only
> provide a single reference for a headline, i.e., not one for the title
> and another one for the custom ID. If your reference is based solely on
> the title, the reference will break whenever you modify the title
> without touching custom ID. I gave an example in an earlier post
> already. This is a regression wrt the current system.

I remain rather confused on this point. Say I have a document with the
following content:

* Some heading
:PROPERTIES:
:CUSTOM_ID: hey
:END:
See [[#hey]] or [[Some heading]]

In an HTML export I see:

<li><a href="#hey">1. Some heading</a></li>
[...] See <a href="#hey">1</a> or <a href="#hey">1</a></p>

In an ASCII export:

1 Some heading
══════════════

  See 1 or 1

In a LaTeX export:

\section{Some heading}
\label{hey}
See \ref{hey} or \ref{hey}

etc.

I don't see how my code affects custom IDs.

> In a nutshell:
>
> - there are very interesting points in your proposal;

Glad you've found some things of interest.

> - it is not applicable at the moment;

I'm guessing this is solely due to punycode?

> - it greatly improves references for English language, it is slightly
>   better for latin languages, and worse for non-latin ones;
>
> - it does not guarantee link stability during export;

Indeed. However no approach that doesn't cache every heading with every
export does, and I find this /significantly/ improves stability.

> - it introduces a regression wrt custom ID.

See my confusion above.

> Link stability is still an issue, even if the proposal gives a false
> sense of security in that area. I don't think we can solve it without
> creating a cache for export, where you store all previous references for
> a given file. Even this is not sufficient, because you can export
> buffers not attached to files.

To me this is a case of "don't let the perfect be the enemy of the
good", though I do see that a false sense of security may be
problematic, I consider the benefits to outweigh this.

I hope you've found this reply more useful than my last,

Timothy.


  reply	other threads:[~2021-05-02 20:16 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 23:28 stability of toc links Samuel Wales
2020-12-08 23:30 ` Samuel Wales
2020-12-09  1:39   ` Tom Gillespie
2020-12-12 21:51     ` TRS-80
2020-12-12 22:47       ` TRS-80
2022-10-10  0:49     ` Samuel Wales
2022-10-10  1:37       ` Samuel Wales
2022-10-11  3:12         ` Robert Weiner
2022-10-11 11:25         ` Ihor Radchenko
2020-12-09  2:48 ` TEC
2020-12-09  8:45   ` Diego Zamboni
2020-12-09  9:15   ` Carsten Dominik
2020-12-09 21:25     ` Samuel Wales
2020-12-10  9:55       ` Carsten Dominik
2020-12-10 12:49         ` TEC
2020-12-10 14:36           ` TEC
2020-12-11  7:51             ` Carsten Dominik
2020-12-19  6:41               ` Carsten Dominik
2020-12-19 11:22                 ` Ihor Radchenko
2021-04-18 21:02   ` Samuel Wales
2020-12-14 10:46 ` Dominique Dumont
2021-04-18 10:32 ` Nicolas Goaziou
2021-04-20  0:58   ` Samuel Wales
2021-04-20 10:34     ` Nicolas Goaziou
2021-04-21  0:33       ` Samuel Wales
2021-04-21  8:32         ` Nicolas Goaziou
2021-04-21 13:32           ` Samuel Loury
2021-04-21 16:24             ` Nicolas Goaziou
2021-04-23 15:15               ` Maxim Nikulin
2021-04-23 20:46                 ` Samuel Wales
2021-04-23 20:48                   ` Samuel Wales
2021-04-23 20:51                     ` Samuel Wales
2021-04-24  3:05                 ` Timothy
2021-04-25 17:01               ` Dominique Dumont
2021-04-30  6:24                 ` Timothy
2021-04-30 12:20                   ` Maxim Nikulin
2021-04-21 23:20             ` Samuel Wales
2021-04-21 23:30               ` Samuel Wales
2021-04-29 21:40                 ` TRS-80
2021-04-29 22:18                   ` Samuel Wales
2021-04-30  1:48                     ` TRS-80
2021-04-30  5:13                     ` Tim Cross
2021-04-30 10:02                       ` Samuel Loury
2021-04-30 11:12                         ` Nicolas Goaziou
2021-04-30 21:12                           ` Tim Cross
2021-05-01 12:36                             ` Nicolas Goaziou
2021-05-01 12:48                               ` Timothy
2021-05-01 13:13                                 ` Nicolas Goaziou
2021-05-01 13:47                                   ` Timothy
2021-05-01 14:09                                     ` Nicolas Goaziou
2021-05-01 14:22                                       ` Timothy
2021-05-02 12:10                                         ` Nicolas Goaziou
2021-05-02 20:16                                           ` Timothy [this message]
2022-10-11 11:44                                             ` [FR] [Revived] Human readable / customizable link anchors during export (was: stability of toc links) Ihor Radchenko
2022-10-11 19:20                                               ` [FR] [Revived] Human readable / customizable link anchors during export Kévin Le Gouguec
2022-10-12  6:33                                                 ` Ihor Radchenko
2022-10-12 17:38                                                   ` Kévin Le Gouguec
2021-05-01  3:08                           ` stability of toc links Greg Minshall

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

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

  git send-email \
    --in-reply-to=8735v4hoxl.fsf@gmail.com \
    --to=tecosaur@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=konubinix@gmail.com \
    --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 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.