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개의 좋아요

GitHub를 살펴보면, 이를 구현하는 것은 아마도 다음 목록에 항목을 추가하는 것만으로 충분할 것입니다:
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/white-lister.js#L181-L183

다만, 이러한 속성을 도입하면 HTML-to-markdown 변환기가 해당 속성을 인식하지 못할 수 있습니다. 하지만 위에서 보여준 것처럼, 현재 markdown-it는 이러한 속성을 나타내는 마크다운 구문을 처리할 수조차 없습니다. 이를 위해 한 단계 더 나아가 CommonMark에서 목록 유형을 구현하는 것이 바람직할 수 있습니다…

2개의 좋아요

이에 대한 계획은 없습니다.

이것이 부재하면, 문서 참조에 번호 대신 마커를 사용하는 공식 문서, 법적 문서, 소프트웨어 라이선스, 기타 모든 문서를 인용하는 것이 매우 어려워집니다.

1개의 좋아요

해당 목록에 래퍼와 일부 CSS를 추가하세요

게시글에서 사용:

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

테마에 추가:

.cooked div[data-wrap="letterlist"]
  list-style: upper-alpha;
}
1개의 좋아요

목록 장식을 임의로 적용하는 것이 목표라면 좋은 해결책이지만, HTML의 type 속성은 목록 마커의 차이가 단순한 장식을 넘어 의미론적으로 중요한 상황, 즉 항목이 번호나 문자로 참조되는 법적 또는 기술적 문서와 같은 경우에 특히 사용하도록 설계되었습니다. MDN 문서(<ol> HTML ordered list element - HTML | MDN)에는 다음과 같이 명시되어 있습니다.

목록 번호의 유형이 중요하지 않다면(항목이 번호/문자로 참조되는 법적 또는 기술적 문서와 같은 경우 제외), CSS의 list-style-type 속성을 사용하는 것이 좋습니다.

HTML 4.01에서는 이 속성이 순수하게 스타일링 목적이라는 이유로 비추천(deprecated) 처리되었지만, MDN에서 설명한 대로 참조 목록을 인코딩하기 위한 특정 목적으로 HTML5에서 다시 도입되었습니다. 그만큼 보편적인 요구 사항이기 때문입니다.

1개의 좋아요

해당 솔루션을 시도해 보니 동작하더군요. CSS를 다음과 같이 수정하면 됩니다(첫 줄에 ol {가 빠져 있었습니다):

.cooked div[data-wrap="letterlist"] ol {
  list-style: upper-alpha;
}

하지만 에디터 미리보기 창에는 표시가 되지 않는데, 이는 대부분의 사용자들에게 다소 문제가 될 것 같습니다. 웹 브라우저로 인스펙션을 시도해 봤는데, 커스텀 CSS가 미리보기에 로드되거나 적용되지 않는 것으로 보입니다(전문가는 아니므로 제 추측이 틀렸을 수도 있습니다).

@Falco 님, 이 문제를 해결할 수 있는 방법이 떠오르시나요?

1개의 좋아요

이제 html이 지원되는 것 같습니다:

  1. 이 항목
  2. 또 다른 항목
  3. 다른 항목
<ol type="A">
<li> This thing
<li> Another thing
<li> Something else
</ol>

그리고 A, a, I, i 유형도 지원합니다.

또한 <ol reversed>와 <ol start=>도 지원합니다:

  1. 빵
  2. 칩
  3. 수박
<ol reversed start=36>
<li> Bread
<li> Chips
<li> Watermelon
</ol>

그런 방식으로 HTML을 사용하면 <li> 내부에서 마크다운 해석이 비활성화되는 것 같아서, 사용자에게 제안하기에는 적절하지 않습니다.

1개의 좋아요

이 안에 추가 포맷팅을 사용하려면, 혼용을 지원하지 않으므로 해당 부분도 HTML 버전을 사용해야 할 것 같습니다:

  1. Bread
  2. Chips
  3. Watermelon
<ol reversed start=36>
<li> <b>Bread</b>
<li> <i>Chips</i>
<li> <s>Watermelon</s>
</ol>

알고 있습니다. 말씀드렸듯이, 사용자가 원하는 목록이 약간 다를 뿐이라는 이유만으로 마크업을 완전히 바꾸는 것은 수용할 수 없다고 생각합니다.

아, 그 옵션이 당신에게 적합하지 않군요. 죄송합니다.

기존 솔루션을 조정하는 방법에 대해 도움을 요청하는 Development 토픽을 시작해 보시면, 누군가가 도움을 줄 수 있을지도 모릅니다. :+1:

1개의 좋아요