本站消息

站长简介/公众号


站长简介:高级软件工程师,曾在阿里云,每日优鲜从事全栈开发工作,利用周末时间开发出本站,欢迎关注我的微信公众号:程序员总部,程序员的家,探索程序员的人生之路!分享IT最新技术,关注行业最新动向,让你永不落伍。了解同行们的工资,生活工作中的酸甜苦辣,谋求程序员的最终出路!

 价值13000svip视频教程,前端大神匠心打造,零基础前端开发工程师视频教程全套,基础+进阶+项目实战,包含课件和源码

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

如何覆盖有序列表中一个特定 li 的编号

发布于2021-10-23 03:28     阅读(121)     评论(0)     点赞(27)     收藏(1)


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

例如,这里有一些原文:

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

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

<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>

它呈现(显然)为:

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.

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

即,如何将 中的第三项更改ol2A,并将第四项更改为3

这是一个JS 小提琴,可以轻松上手!:)


解决方案


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

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

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

所以我会选择这样的:

<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>

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

<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>



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.qianduanheidong.com/blog/article/208445/7206344387e2b9ff2eb3/

来源:前端黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

27 0
收藏该文
已收藏

评论内容:(最多支持255个字符)