如何覆盖有序列表中一个特定 li 的编号 [英] How do I override the numbering for one specific li in an ordered list

查看:18
本文介绍了如何覆盖有序列表中一个特定 li 的编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在转录带有有序列表的法律文件,但有一个问题.立法者很懒惰,在第 2 条和第 3 条之间添加新条款时,他们将其命名为 2A.

举个例子,下面是一些原文:

<块引用>

6 叛国罪
(1) 任何人以使用武力或展示武力或以任何其他违宪方式废除或颠覆或中止或中止,或企图或共谋废除或颠覆或中止或中止宪法的人应被定罪叛国罪.
(2) 任何人协助、教唆或配合第 (1) 款所述行为,同样应构成叛国罪.
(2A) 第 (1) 款或第 (2) 款所述的叛国罪,不得由包括最高法院和高等法院在内的任何法院生效.
(3) Majlis-e-Shoora(议会)应依法规定对被判犯有叛国罪的人的惩罚.

当转换为 HTML 时,它被标记为:

<div><div>6&mdash;<em>叛国罪</em></div>

<div><ol type="1"><li>任何人以使用武力或展示武力或任何其他违宪方式废除或颠覆或中止或中止,或企图或共谋废除或颠覆或中止或中止宪法的,应犯有叛国罪.</li><li>任何人协助、教唆或合作实施第 (1) 条所述的行为,同样应构成叛国罪.</li><li>第(1)款或第(2)款所述的叛国罪,包括最高法院和高等法院在内的任何法院均不得认可.</li><li>Majlis-e-Shoora(议会)应依法规定对被判犯有叛国罪的人的惩罚.</li></ol>

</文章>

它呈现(显然)为:

6——叛国罪1. 任何人以使用武力或展示武力或任何其他违宪方式废除或颠覆或中止或中止,或企图或共谋废除或颠覆或中止或中止宪法的人,将被视为犯有以下罪行:叛国罪.2. 任何人协助、教唆或合作第(1)款所述的行为,同样构成叛国罪.3. 第(1)款或第(2)款所述的叛国罪,不得为包括最高法院和高等法院在内的任何法院认可.4. Majlis-e-Shoora(议会)应依法规定对被判犯有叛国罪的人的惩罚.

<小时>

问题:如何覆盖特定 li 上的数字并从下一次开始重新开始计数?

即,如何将 ol 中的第三项更改为 2A,将第四项更改为 3.

这是一个 JS fiddle,让您轻松上手!:)

解决方案

我建议不要使用 ol,也不要使用其他列表元素.

仅仅因为内容被编号,并不意味着必须使用 ol(也不一定适合使用它).从语义上讲,它可以表示为段落的编号序列.如果您有层次结构(即嵌套列表),则可以保证使用 ol,但这里似乎并非如此.

即使 if ol 在语义上也是合适的:如果你不能用 startvalue 表示编号(在您的情况下,似乎您不能),内容仅与 CSS 结合使用才有意义.但是我们不应该依赖 CSS 来传达内容的含义.没有 CSS 支持的用户代理(或应用覆盖相关部分的用户特定样式表的用户代理)将获得不同的编号.在引用这些列表项时,可能会导致误解,甚至可能是严重的误解(尤其是在法律文件的情况下).

所以我会选择这样的:

<h2>6叛国罪</h2><p>(1) 任何人通过使用武力或展示武力或任何其他违宪的方式废除或颠覆或暂停或暂停或企图或共谋废除或颠覆或暂停或暂停宪法意味着犯有叛国罪.</p><p>(2) 任何人协助、教唆或合作实施第 (1) 条所述的行为,同样应构成叛国罪.</p><p>(2A) 第 (1) 款或第 (2) 款所述的叛国罪,不得由包括最高法院和高等法院在内的任何法院生效.</p><p>(3) Majlis-e-Shoora(议会)应依法规定对被判犯有叛国罪的人的惩罚.</p></节>

这也允许您使用 a 作为数字,以便可以链接特定的子句:

<h2>6叛国罪</h2><p id="6-1"><a href="#6-1">(1)</a>任何人以使用武力、展示武力或任何其他违宪手段废除、颠覆或中止或中止,或企图或共谋废除、颠覆或中止或中止宪法的,均属叛国罪..</p><p id="6-2"><a href="#6-2">(2)</a>任何协助或教唆或合作实施条款<a href="#6-1">(1)</a>中提到的行为的人;也将被判叛国罪.</p><p id="6-2A"><a href="#6-2A">(2A)</a>条款<a href="#6-1">(1)</a>中提到的叛国罪.或子句<a href="#6-2">(2)</a>不得由包括最高法院和高等法院在内的任何法院验证.</p><p id="6-3"><a href="#6-3">(3)</a>Majlis-e-Shoora(议会)应依法规定对被判犯有叛国罪的人的惩罚.</p></节>

I'm transcribing legal documents that come with ordered lists, but there's a catch. Law-makers are lazy and when adding a new clause between clauses 2, and 3, they name it 2A.

As an example, here's some original text:

6 High treason
(1) Any person who abrogates or subverts or suspends or holds in abeyance, or attempts or conspires to abrogate or subvert or suspend or hold in abeyance, the Constitution by use of force or show of force or by any other unconstitutional means shall be guilty of high treason.
(2) Any person aiding or abetting or collaborating the acts mentioned in clause (1) shall likewise be guilty of high treason.
(2A) An act of high treason mentioned in clause (1) or clause (2) shall not be validated by any court including the Supreme Court and a High Court.
(3) Majlis-e-Shoora (Parliament) shall by law provide for the punishment of persons found guilty of high treason.

When coverted to HTML, it's marked up as:

<article>
  <div>
    <div>6&mdash;<em>High treason</em></div>
  </div>
  <div>
    <ol type="1">
    <li>Any person who abrogates or subverts or suspends or holds in abeyance, or attempts or conspires to abrogate or subvert or suspend or hold in abeyance, the Constitution by use of force or show of force or by any other unconstitutional means shall be guilty of high treason.</li>
    <li>Any person aiding or abetting  or collaborating the acts mentioned in clause (1) shall likewise be guilty of high treason.</li>
    <li>An act of high treason mentioned in clause (1) or clause (2) shall not be validated by any court including the Supreme Court and a High Court.</li>
    <li>Majlis-e-Shoora (Parliament) shall by law provide for the punishment of persons found guilty of high treason.</li>
    </ol>
  </div>
</article>

It renders (obviously) as:

6—High treason
  1. Any person who abrogates or subverts or suspends or holds in abeyance, or attempts or conspires to abrogate or subvert or suspend or hold in abeyance, the Constitution by use of force or show of force or by any other unconstitutional means shall be guilty of high treason.
  2. Any person aiding or abetting or collaborating the acts mentioned in clause (1) shall likewise be guilty of high treason.
  3. An act of high treason mentioned in clause (1) or clause (2) shall not be validated by any court including the Supreme Court and a High Court.
  4. Majlis-e-Shoora (Parliament) shall by law provide for the punishment of persons found guilty of high treason.


Question: How can I override the number on a specific li and restart the count from the next onwards?

I.e, how do I change 3rd item in the ol to be 2A, and 4th to be 3.

Here's a JS fiddle to make it easy to get started! :)

解决方案

I would suggest not to use ol, nor another list element.

Just because content is numbered, doesn’t mean that ol has to be used (nor that it’s necessarily appropriate to use it). Semantically, it could be represented as a numbered sequence of paragraphs. Using ol could be warranted if you have a hierarchy (i.e., nested lists), but that doesn’t seem to be the case here.

Even if ol is semantically appropriate: If you can’t represent the numbering with start and value (and it seems that you can’t, in your case), the content only makes sense in combination with CSS. But we shouldn’t rely on CSS for conveying the meaning of the content. A user agent without CSS support (or a user agent applying a user-specific style sheet that overwrites the relevant part) would get a different numbering. When making references to these list items, it can lead to misunderstandings, possibly critical ones (especially in the case of legal documents).

So I would go with something like this:

<section>
  <h2>6 High treason</h2>

  <p>(1) Any person who abrogates or subverts or suspends or holds in abeyance, or attempts or conspires to abrogate or subvert or suspend or hold in abeyance, the Constitution by use of force or show of force or by any other unconstitutional means shall be guilty of high treason.</p>
  <p>(2) Any person aiding or abetting or collaborating the acts mentioned in clause (1) shall likewise be guilty of high treason.</p>
  <p>(2A) An act of high treason mentioned in clause (1) or clause (2) shall not be validated by any court including the Supreme Court and a High Court.</p>
  <p>(3) Majlis-e-Shoora (Parliament) shall by law provide for the punishment of persons found guilty of high treason.</p>

</section>

This would also allow you to use a for the numbers so that specific clauses can be linked:

<section id="6">
  <h2>6 High treason</h2>

  <p id="6-1">
    <a href="#6-1">(1)</a>
    Any person who abrogates or subverts or suspends or holds in abeyance, or attempts or conspires to abrogate or subvert or suspend or hold in abeyance, the Constitution by use of force or show of force or by any other unconstitutional means shall be guilty of high treason.
  </p>

  <p id="6-2">
    <a href="#6-2">(2)</a>
    Any person aiding or abetting or collaborating the acts mentioned in clause <a href="#6-1">(1)</a> shall likewise be guilty of high treason.
  </p>

  <p id="6-2A">
    <a href="#6-2A">(2A)</a>
    An act of high treason mentioned in clause <a href="#6-1">(1)</a> or clause <a href="#6-2">(2)</a> shall not be validated by any court including the Supreme Court and a High Court.
  </p>

  <p id="6-3">
    <a href="#6-3">(3)</a>
    Majlis-e-Shoora (Parliament) shall by law provide for the punishment of persons found guilty of high treason.
  </p>

</section>

这篇关于如何覆盖有序列表中一个特定 li 的编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆