For talk pages, it would be useful to have an `id` attribute on each list item (talk page comments using `:` are <dd> list items) so that individual comments can be referenced. Perhaps other lists would benefit from being able to be referenced by default (as headings are).
Strawman proposal is to automatically assign hierarchical ids (so that adding new subitems---which are replies , in a talk page context---does not shift existing ids), something like:
wikitext:
```
== Thread 1 ==
: This is comment 1
:: This is a reply to comment 1
: This is comment 2
```
which turns into the following output (note that this is also valid wikitext for this list, but the point of this task is that authors are *not required* to write this; instead the IDs are automatically generated):
```
<h2 id="thread_1">Thread 1</h2>
<dl><dd id="thread_1-1">This is comment 1
<dl><dd id="thread_1-1-1">This is a reply to comment 21</dd></dl>
</dd><dd id="thread_1-2">This is comment 2
</dd></dl>
```
Alternatively/in addition, a "permanent" or "more readable" id could be manually assigned in the editor, which would then get attached to the list item using the syntax proposed in {T230658}.
These IDs are scoped to an individual talk pagAlternatively/in addition, a "permanent" or "more readable" id could be manually assigned, which would override (or supplement?) the automatically-assigned id. This would get expressed either using explicit `<dd id="...">` syntax (sigh), with new cleaner syntax (for example, so they don't need to be globally uniqueas proposed in {T230658}), which should greatly help makeor via some other mechanism (see the note at then human-friendly bottom of this task).
These assigned list IDs are scoped to an individual article or talk page, so they don't need to be globally unique, which should greatly help make then human-friendly.
In fact, instead of hierarchically-assigned IDs, we could generate them based on the list item/comment content, like we do for section ids. We'd want to truncate to a certain length, and we'd probably want to use thea manual syntax of {T230658}override to preserve the original ID if/when the list item/comment is edited. U
As a strawman, using the timestamp as a ID prefix helps ensure that a bunch of comments which all start with "approved" don't need a lot of automatic deduplication:
```
== Thread 1 ==
: This is comment 1 {{#~|UserA|20190818 10:23:45}}
:: This is a reply to comment 21 {{#~|UserB|20190818 10:23:45.1}}
: This is comment 2 {{#~|UserC|20190818 10:23:45.15}}
<h2 id="thread_1">Thread 1</h2>
<dl><dd id="20190818T1213-this_is">This is comment 1
<dl><dd id="20190818T1214-this_is">This is a reply to comment 21</dd></dl>
</dd><dd id="20190818T1215-this_originally_said">This is comment 2
</dd></dl>
```
(That last item might serialize to wikitext as: `: id=20190818T1215-this_originally_said <<< This is comment 2 >>>`.)
Once editedHowever, this can look ugly if it appears in wikitext -- even as a link: [[Talk:Foo#20190818T1214-this-is]]. Readability needs to be traded off against being 'unique by default' (as opposed to requiring a postprocessing pass to make IDs unique, as section headings currently do).
As a point of comparison, phabricator discussions currently include an opaque numeric tag, but one which is substantially shorter than a full human-readable timestamp. Since `[[phab:T230659#5431727]]` is considered acceptable, that could be considered a reasonable proxy for the acceptable length of an opaque comment identifier. Note that, unlike in some previous comment-linking proposals, we are still preserving the context of the discussion -- in the phab case via the `T230659` prefix, although as an opaque number itself that's not great and phab itself will expand that with hovertext in most UX. In the proposed Talk page context the prefix would be the title of the task page: `[[Talk:Foo#5431727]]` or something like that.
As a special case of lists, talk pages aren't as often edited (we try to leave existing comments alone!), but they are usually archived after a period of time, which could break existing links. We'd need some way to update references to point to the archived talk page instead. You could either do this with a bot that could just comb through looking for old references, or more "cleverly" with something like:
```
[[Special:Talk/PageName#comment-id]]
```
where that special page would redirect to the appropriate archive page for the given comment id.
Note: '''This task is just for automatically-assigning default list item ids.''' If you want to make list item ids persistent across edits to the wikitext, then make a proposal in a separate task for how to do so. {T230658} is one such proposal, where the comment ID would appear as an explicit ID attribute in wikitext. You could also imagine persisting list items IDs by using a separate database table of some sort that would record assigned IDs and perhaps update this table when wikitext is edited. I don't have a good idea for how to do that, but feel free to make a proposal.