tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* [PATCH 1/2] HTML: Add "lang" attributes
@ 2022-07-17  7:37 Anna Vyalkova
  2022-07-17  7:37 ` [PATCH 2/2] HTML: mark some tables as used for layout only Anna Vyalkova
  0 siblings, 1 reply; 2+ messages in thread
From: Anna Vyalkova @ 2022-07-17  7:37 UTC (permalink / raw)
  To: tech

Set global man.cgi language to English.
Set results and manpage language to unknown.

Allows browsers to use the right font and screen readers - the right
voice.
---

Proper localization support can be only done via JS hacks at the moment
and there is no simple solution AFAIK.

How about introducing a new macro for manpage language? Although it
won't be really useful as most localized manpages use legacy man(7).

 cgi.c       | 12 +++++++-----
 man_html.c  |  2 +-
 mdoc_html.c |  2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/cgi.c b/cgi.c
index 76baddb6..79f80ffe 100644
--- a/cgi.c
+++ b/cgi.c
@@ -381,7 +381,7 @@ resp_begin_html(int code, const char *msg, const char *file)
 	resp_begin_http(code, msg);
 
 	printf("<!DOCTYPE html>\n"
-	       "<html>\n"
+	       "<html lang=\"en\">\n"
 	       "<head>\n"
 	       "  <meta charset=\"UTF-8\"/>\n"
 	       "  <meta name=\"viewport\""
@@ -727,11 +727,11 @@ pg_searchres(const struct req *req, struct manpage *r, size_t sz)
 	puts("</header>");
 
 	if (sz > 1) {
-		puts("<nav>");
+		puts("<nav lang=\"\">");
 		puts("<table class=\"results\">");
 		for (i = 0; i < sz; i++) {
 			printf("  <tr>\n"
-			       "    <td>"
+			       "    <td lang=\"en\">"
 			       "<a class=\"Xr\" href=\"/");
 			if (*scriptname != '\0')
 				printf("%s/", scriptname);
@@ -907,9 +907,11 @@ resp_format(const struct req *req, const char *file)
 	int		 usepath;
 
 	if (-1 == (fd = open(file, O_RDONLY))) {
-		puts("<p role=\"doc-notice\">\n"
+		puts("<main>\n"
+		     "<p role=\"doc-notice\">\n"
 		     "  You specified an invalid manual file.\n"
-		     "</p>");
+		     "</p>\n"
+		     "</main>");
 		return;
 	}
 
diff --git a/man_html.c b/man_html.c
index f931dcb9..fe5f3ea6 100644
--- a/man_html.c
+++ b/man_html.c
@@ -132,7 +132,7 @@ html_man(void *arg, const struct roff_meta *man)
 	}
 
 	man_root_pre(man, h);
-	t = print_otag(h, TAG_MAIN, "c", "manual-text");
+	t = print_otag(h, TAG_MAIN, "c?", "manual-text", "lang", "");
 	print_man_nodelist(man, n, h);
 	print_tagq(h, t);
 	man_root_post(man, h);
diff --git a/mdoc_html.c b/mdoc_html.c
index 7dab43e7..fdf113cf 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -302,7 +302,7 @@ html_mdoc(void *arg, const struct roff_meta *mdoc)
 	}
 
 	mdoc_root_pre(mdoc, h);
-	t = print_otag(h, TAG_MAIN, "c", "manual-text");
+	t = print_otag(h, TAG_MAIN, "c?", "manual-text", "lang", "");
 	print_mdoc_nodelist(mdoc, n, h);
 	print_tagq(h, t);
 	mdoc_root_post(mdoc, h);
-- 
2.35.1

--
 To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-17  7:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-17  7:37 [PATCH 1/2] HTML: Add "lang" attributes Anna Vyalkova
2022-07-17  7:37 ` [PATCH 2/2] HTML: mark some tables as used for layout only Anna Vyalkova

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