source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: If an .Xr macro contains a section argument, write an aria-label
Date: Sat, 25 Jun 2022 07:44:55 -0500 (EST)	[thread overview]
Message-ID: <3365d32ece7153e2@mandoc.bsd.lv> (raw)

Log Message:
-----------
If an .Xr macro contains a section argument, write an aria-label attribute
such that users of screen readers aren't forced to listen to lengthy and 
distracting readings like "mdoc, left parenthesis, 7, right parenthesis".

Based on a patch from Anna Vyalkova <cyber at sysrq dot in>,
significantly tweaked by me.

Modified Files:
--------------
    mandoc:
        LICENSE
        mdoc_html.c

Revision Data
-------------
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_html.c,v
retrieving revision 1.343
retrieving revision 1.344
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.343 -r1.344
--- mdoc_html.c
+++ mdoc_html.c
@@ -1,7 +1,8 @@
 /* $Id$ */
 /*
- * Copyright (c) 2014-2021 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014-2022 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2022 Anna Vyalkova <cyber@sysrq.in>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -665,26 +666,34 @@ mdoc_nm_pre(MDOC_ARGS)
 static int
 mdoc_xr_pre(MDOC_ARGS)
 {
-	if (NULL == n->child)
+	char	*name, *section, *label;
+
+	if (n->child == NULL)
 		return 0;
 
+	name = n->child->string;
+	if (n->child->next != NULL) {
+		section = n->child->next->string;
+		mandoc_asprintf(&label, "%s, section %s", name, section);
+	} else
+		section = label = NULL;
+
 	if (h->base_man1)
-		print_otag(h, TAG_A, "chM", "Xr",
-		    n->child->string, n->child->next == NULL ?
-		    NULL : n->child->next->string);
+		print_otag(h, TAG_A, "chM?", "Xr",
+		    name, section, "aria-label", label);
 	else
-		print_otag(h, TAG_A, "c", "Xr");
+		print_otag(h, TAG_A, "c?", "Xr", "aria-label", label);
 
-	n = n->child;
-	print_text(h, n->string);
+	free(label);
+	print_text(h, name);
 
-	if (NULL == (n = n->next))
+	if (section == NULL)
 		return 0;
 
 	h->flags |= HTML_NOSPACE;
 	print_text(h, "(");
 	h->flags |= HTML_NOSPACE;
-	print_text(h, n->string);
+	print_text(h, section);
 	h->flags |= HTML_NOSPACE;
 	print_text(h, ")");
 	return 0;
Index: LICENSE
===================================================================
RCS file: /home/cvs/mandoc/mandoc/LICENSE,v
retrieving revision 1.22
retrieving revision 1.23
diff -LLICENSE -LLICENSE -u -p -r1.22 -r1.23
--- LICENSE
+++ LICENSE
@@ -4,8 +4,8 @@ With the exceptions noted below, all non
 in the mandoc toolkit are protected by the Copyright of the following
 developers:
 
+Copyright (c) 2010-2022 Ingo Schwarze <schwarze@openbsd.org>
 Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
-Copyright (c) 2010-2021 Ingo Schwarze <schwarze@openbsd.org>
 Copyright (c) 1999, 2004, 2017 Marc Espie <espie@openbsd.org>
 Copyright (c) 2009, 2010, 2011, 2012 Joerg Sonnenberger <joerg@netbsd.org>
 Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
@@ -13,6 +13,7 @@ Copyright (c) 2014 Baptiste Daroussin <b
 Copyright (c) 2016 Ed Maste <emaste@freebsd.org>
 Copyright (c) 2017 Michael Stapelberg <stapelberg@debian.org>
 Copyright (c) 2017 Anthony Bentley <bentley@openbsd.org>
+Copyright (c) 2022 Anna Vyalkova <cyber@sysrq.in>
 Copyright (c) 1998, 2004, 2010, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
 Copyright (c) 2008, 2017 Otto Moerbeek <otto@drijf.net>
 Copyright (c) 2004 Ted Unangst <tedu@openbsd.org>
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


                 reply	other threads:[~2022-06-25 12:44 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=3365d32ece7153e2@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).