source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: In fragment identifiers, use ~%d for ordinal suffixes, and
Date: Mon, 20 Apr 2020 08:07:58 -0500 (EST)	[thread overview]
Message-ID: <8a57bef8102da96d@mandoc.bsd.lv> (raw)

Log Message:
-----------
In fragment identifiers, use ~%d for ordinal suffixes,
and reserve the character '~' for that purpose.

Bug found by validator.w3.org in openssl(1), which contains both a
tag "tls1_2" and a second instance of a tag "tls1", which also resulted
in "tls1_2", causing a clash.  Now, the second instance of "tls1" is
rendered as "tls1~2" instead, employing the newly reserved '~'.

Modified Files:
--------------
    mandoc:
        html.c
    mandoc/regress/man/IP:
        literal.out_html
    mandoc/regress/man/TP:
        literal.out_html
        vert.out_html
    mandoc/regress/mdoc/Bd:
        nested.out_html
    mandoc/regress/mdoc/Sh:
        tag.out_html

Revision Data
-------------
Index: vert.out_html
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/TP/vert.out_html,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/man/TP/vert.out_html -Lregress/man/TP/vert.out_html -u -p -r1.2 -r1.3
--- regress/man/TP/vert.out_html
+++ regress/man/TP/vert.out_html
@@ -4,6 +4,6 @@
 <dl class="Bl-tag">
   <dt id="tag"><a class="permalink" href="#tag">tag</a></dt>
   <dd>text</dd>
-  <dt id="tag_2"><a class="permalink" href="#tag_2">tag</a></dt>
+  <dt id="tag~2"><a class="permalink" href="#tag~2">tag</a></dt>
   <dd>text</dd>
 </dl>
Index: literal.out_html
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/TP/literal.out_html,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lregress/man/TP/literal.out_html -Lregress/man/TP/literal.out_html -u -p -r1.3 -r1.4
--- regress/man/TP/literal.out_html
+++ regress/man/TP/literal.out_html
@@ -8,7 +8,7 @@ literal
 text
 </pre>
 <dl class="Bl-tag">
-  <dt id="tag_2"><a class="permalink" href="#tag_2">tag</a></dt>
+  <dt id="tag~2"><a class="permalink" href="#tag~2">tag</a></dt>
   <dd>
     <pre>
 indented
Index: html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/html.c,v
retrieving revision 1.269
retrieving revision 1.270
diff -Lhtml.c -Lhtml.c -u -p -r1.269 -r1.270
--- html.c
+++ html.c
@@ -383,11 +383,12 @@ html_make_id(const struct roff_node *n, 
 	 * permitted in URL-fragment strings according to the
 	 * explicit list at:
 	 * https://url.spec.whatwg.org/#url-fragment-string
+	 * In addition, reserve '~' for ordinal suffixes.
 	 */
 
 	for (cp = buf; *cp != '\0'; cp++)
 		if (isalnum((unsigned char)*cp) == 0 &&
-		    strchr("!$&'()*+,-./:;=?@_~", *cp) == NULL)
+		    strchr("!$&'()*+,-./:;=?@_", *cp) == NULL)
 			*cp = '_';
 
 	if (unique == 0)
@@ -407,7 +408,7 @@ html_make_id(const struct roff_node *n, 
 
 	if (entry->ord > 1) {
 		cp = buf;
-		mandoc_asprintf(&buf, "%s_%d", cp, entry->ord);
+		mandoc_asprintf(&buf, "%s~%d", cp, entry->ord);
 		free(cp);
 	}
 	return buf;
Index: literal.out_html
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/IP/literal.out_html,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lregress/man/IP/literal.out_html -Lregress/man/IP/literal.out_html -u -p -r1.5 -r1.6
--- regress/man/IP/literal.out_html
+++ regress/man/IP/literal.out_html
@@ -8,7 +8,7 @@ literal
 text
 </pre>
 <dl class="Bl-tag">
-  <dt id="tag_2"><a class="permalink" href="#tag_2">tag</a></dt>
+  <dt id="tag~2"><a class="permalink" href="#tag~2">tag</a></dt>
   <dd>
     <pre>
 indented
@@ -32,7 +32,7 @@ literal
 text
 </pre>
 <dl class="Bl-tag">
-  <dt id="tag_3"><a class="permalink" href="#tag_3">tag</a></dt>
+  <dt id="tag~3"><a class="permalink" href="#tag~3">tag</a></dt>
   <dd>
     <pre>
 indented
@@ -48,7 +48,7 @@ text
   out of indented paragraph</a></h2>
 <p class="Pp">regular text</p>
 <dl class="Bl-tag">
-  <dt id="tag_4"><a class="permalink" href="#tag_4">tag</a></dt>
+  <dt id="tag~4"><a class="permalink" href="#tag~4">tag</a></dt>
   <dd>indented regular text
     <pre>
 indented
Index: nested.out_html
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/nested.out_html,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Bd/nested.out_html -Lregress/mdoc/Bd/nested.out_html -u -p -r1.1 -r1.2
--- regress/mdoc/Bd/nested.out_html
+++ regress/mdoc/Bd/nested.out_html
@@ -8,10 +8,10 @@
 outer text</div>
 regular text
 <div class="Bd Pp
-  Bd-indent" id="outer_2"><a class="permalink" href="#outer_2">outer</a> text
+  Bd-indent" id="outer~2"><a class="permalink" href="#outer~2">outer</a> text
   (4n)
 <div class="Bd Pp
-  Bd-indent" id="inner_2"><a class="permalink" href="#inner_2">inner</a> text
+  Bd-indent" id="inner~2"><a class="permalink" href="#inner~2">inner</a> text
   (2n)</div>
 outer text
 <dl class="Bl-tag">
Index: tag.out_html
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Sh/tag.out_html,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lregress/mdoc/Sh/tag.out_html -Lregress/mdoc/Sh/tag.out_html -u -p -r1.3 -r1.4
--- regress/mdoc/Sh/tag.out_html
+++ regress/mdoc/Sh/tag.out_html
@@ -2,7 +2,7 @@
 </section>
 </section>
 <section class="Sh">
-<h1 class="Sh" id="DESCRIPTION_2"><a class="permalink" href="#DESCRIPTION_2">DESCRIPTION</a></h1>
+<h1 class="Sh" id="DESCRIPTION~2"><a class="permalink" href="#DESCRIPTION~2">DESCRIPTION</a></h1>
 <p class="Pp">Text in duplicate description section.</p>
 </section>
 <section class="Sh">
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


                 reply	other threads:[~2020-04-20 13:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8a57bef8102da96d@mandoc.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).