Ordered lists with non-number markers

Request: Add “type” attribute of <ol> to whitelist. Suggestion to do the same with “reversed” for <ol>, and “value” for <li>, for similar but less common reasons.

Purpose: These attributes are intended for use where the marker of ordered list items itself conveys meaning to the content of the list. Typically this is the case when list items are intended to be referred to via this marker. This is in contrast to CSS list-style-type which is intended where the choice of marker carries no significant purpose. (Though I did see it recommended for forum-wide localization, which is pretty great!)

Background: While attempting to quote an official reference document, I discovered an apparent limitation in list formatting which prevents doing so accurately. Quite often, list markers are purely stylistic. However, they are occasionally used to facilitate reference in list-heavy documents. For example, in official and legal documents, a list item (or sub-item) might be referred to by list marker: “Official Document Article I, section 1(a)(i)”

For Markdown, there’s no mention in the CommonMark specification, and indeed it specifies only digits, 0-9. But while most interpreters don’t permit letters for lists(including markdown-it), a couple do:

I’m uncertain of whether a standard method is available in BBCode, to the extent anything is standard in BBCode. I was unable to find anything more advanced than starting at an arbitrary digit. BBCode list tags don’t appear used by Discourse, anyway.

With HTML and HTML+style, neither produce the correct result:

3 Mi Piace

Looking at GitHub, implementing this would likely be simply a matter of adding them to this list:
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/white-lister.js#L181-L183

Though I do notice that introducing these will leave the HTML-to-markdown converter unaware of these attributes. But as demonstrated above, markdown-it currently can’t handle markdown syntax representing these anyway. For that, it may be desirable to go a step further and implement list types in CommonMark…

2 Mi Piace

There are no plans for this.

The lack of this makes it very difficult to quote official documents, legal documents, software licenses, or anything else which use non-number markers for document references.

1 Mi Piace

Add a wrapper to those lists and some CSS

In posts use:

[wrap="letterlist"]
1. is the first
2. is the second.
3. is the third
[/wrap]

IN your theme add:

.cooked div[data-wrap="letterlist"]
  list-style: upper-alpha;
}
1 Mi Piace

That’s a good solution if the goal is arbitrary list decorations, but the HTML type attribute is specifically meant for semantically-meaningful situations where the difference between list markers are more than decorative. From <ol>: The Ordered List element - HTML: HyperText Markup Language | MDN

Unless the type of the list number matters (like legal or technical documents where items are referenced by their number/letter), use the CSS list-style-type property instead.

It’s a common enough need that although the HTML attribute was deprecated in HTML 4.01 (with justification of it being purely stylistic), it was subsequently re-introduced in HTML5 for the specific purpose of encoding reference lists as described by MDN.

1 Mi Piace

Ho provato a usare questa soluzione e funziona, correggendo il CSS nel modo seguente (alla prima riga mancava ol {):\n\ncss\n.cooked div[data-wrap=\"letterlist\"] ol {\n list-style: upper-alpha;\n}\n\nTuttavia non riesco a farlo visualizzare nella finestra di anteprima dell’editor, il che sarà un problema per la maggior parte dei miei utenti. Ho provato a ispezionare con il browser web e sembra che il CSS personalizzato non venga caricato o applicato all’anteprima (non sono un professionista, quindi potrei sbagliarmi).\n\nC’è un modo che ti viene in mente per risolvere questo problema, @Falco?

1 Mi Piace

Credo che l’HTML sia ora supportato:

  1. Questa cosa
  2. Un'altra cosa
  3. Qualcos'altro
<ol type="A">
<li>Questa cosa
<li>Un'altra cosa
<li>Qualcos'altro
</ol>

E i tipi A, a, I e i.

Anche reversed e start= come questi:

  1. Pane
  2. Patatine
  3. Anguria
<ol reversed start=36>
<li>Pane
<li>Patatine
<li>Anguria
</ol>

Sembra che l’uso dell’HTML in quel modo disabiliti l’interpretazione di Markdown all’interno di <li>, quindi non è accettabile che io lo proponga agli utenti.

1 Mi Piace

Per fare uso di formattazione aggiuntiva al loro interno, penso che dovresti usare anche la versione HTML, poiché non ama mescolare:

  1. Pane
  2. Patatine
  3. Anguria
<ol reversed start=36>
<li> <b>Pane</b>
<li> <i>Patatine</i>
<li> <s>Anguria</s>
</ol>

Lo so. Come ho detto, non lo trovo accettabile da proporre ai miei utenti: cambia completamente il markup solo perché desideri un elenco leggermente diverso.

Mi dispiace, ma questa non è un’opzione accettabile per te.

Forse se avvii un argomento Dev chiedendo aiuto per modificare la tua soluzione esistente, qualcuno potrà assisterti. :+1:

1 Mi Piace