source@mandoc.bsd.lv
 help / color / Atom feed
* mandoc: In fragment identifiers, use ~%d for ordinal suffixes, and 
@ 2020-04-20 13:07 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2020-04-20 13:07 UTC (permalink / raw)
  To: source

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 13:07 mandoc: In fragment identifiers, use ~%d for ordinal suffixes, and schwarze

source@mandoc.bsd.lv

Archives are clonable: git clone --mirror http://inbox.vuxu.org/mandoc-source

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git