emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Timothy <tecosaur@gmail.com>
To: org-mode-email <emacs-orgmode@gnu.org>
Subject: [PATCH] html export: remove W3C warning, improve accessibility
Date: Mon, 07 Jun 2021 02:02:38 +0800	[thread overview]
Message-ID: <87pmwy50sh.fsf@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 711 bytes --]

Hi All,

Following on from my comments /ages/ ago, I have done some more work to
improve the HTML export. I intend to push it if I don't hear any
complaints. Please let me know if anything looks dodgy, or if anything
should also be improved with this patch :)

This patch:
- Resolves a W3C warning about type="text/css" in <style>
- Removes a docstring reference to IE8- (urgh!)
- Adds some ARIA roles to improve accessibility (let me know if you spot
anything else that could benefit from them being added).

Running the default html export through the W3C validator with my
massive Org-based config now results in nothing other than complaints
about dodgy unicode characters (not Org's fault) :)

--
Timothy


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html-Resolve-W3C-warning-improve-a11y.patch --]
[-- Type: text/x-patch, Size: 4085 bytes --]

From 722d61e5cc49153428c0858ab83ee1db5ee5c1c6 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Mon, 7 Jun 2021 01:51:45 +0800
Subject: [PATCH] ox-html: Resolve W3C warning, improve a11y

* lisp/ox-html.el (org-html-style-default, org-html-head): Remove
unwarranted type="text/css" from <style> (W3C warning).
(org-html-html5-fancy): Remove note about IE8- from docstring.
(org-html-footnote-section, org-html-template, org-html-toc,
org-html-footnote-reference): Add some ARIA roles to improve
accessibility.
---
 lisp/ox-html.el | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 8f8470bb9..bd6771a76 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -260,7 +260,7 @@ (defcustom org-html-scripts
   :type 'string)
 
 (defcustom org-html-style-default
-  "<style type=\"text/css\">
+  "<style>
   #content { max-width: 60em; margin: auto; }
   .title  { text-align: center;
              margin-bottom: .2em; }
@@ -1060,13 +1060,7 @@ (defcustom org-html-doctype "xhtml-strict"
 
 (defcustom org-html-html5-fancy nil
   "Non-nil means using new HTML5 elements.
-This variable is ignored for anything other than HTML5 export.
-
-For compatibility with Internet Explorer, it's probably a good
-idea to download some form of the html5shiv (for instance
-https://code.google.com/p/html5shiv/) and add it to your
-HTML_HEAD_EXTRA, so that your pages don't break for users of IE
-versions 8 and below."
+This variable is ignored for anything other than HTML5 export."
   :group 'org-export-html
   :version "24.4"
   :package-version '(Org . "8.0")
@@ -1472,7 +1466,7 @@ (defcustom org-html-head ""
 
 For example, a valid value would be:
 
-   <style type=\"text/css\">
+   <style>
       p { font-weight: normal; color: gray; }
       h1 { color: black; }
       .title { text-align: center; }
@@ -1818,12 +1812,12 @@ (defun org-html-footnote-section (info)
 		    (anchor (org-html--anchor
 			     (format "fn.%d" n)
 			     n
-			     (format " class=\"footnum\" href=\"#fnr.%d\"" n)
+			     (format " class=\"footnum\" href=\"#fnr.%d\" role=\"doc-backlink\"" n)
 			     info))
 		    (contents (org-trim (org-export-data def info))))
 		(format "<div class=\"footdef\">%s %s</div>\n"
 			(format (plist-get info :html-footnote-format) anchor)
-			(format "<div class=\"footpara\">%s</div>"
+			(format "<div class=\"footpara\" role=\"doc-footnote\">%s</div>"
 				(if (not inline?) contents
 				  (format "<p class=\"footpara\">%s</p>"
 					  contents))))))))
@@ -2120,7 +2114,7 @@ (defun org-html-template (contents info)
 	  (if subtitle
 	      (format
 	       (if html5-fancy
-		   "<p class=\"subtitle\">%s</p>\n"
+		   "<p class=\"subtitle\" role=\"doc-subtitle\">%s</p>\n"
 		 (concat "\n" (org-html-close-tag "br" nil info) "\n"
 			 "<span class=\"subtitle\">%s</span>\n"))
 	       (org-export-data subtitle info))
@@ -2321,14 +2315,14 @@ (defun org-html-toc (depth info &optional scope)
 			 (org-export-get-relative-level headline info)))
 		 (org-export-collect-headlines info depth scope))))
     (when toc-entries
-      (let ((toc (concat "<div id=\"text-table-of-contents\">"
+      (let ((toc (concat "<div id=\"text-table-of-contents\" role=\"doc-toc\">"
 			 (org-html--toc-text toc-entries)
 			 "</div>\n")))
 	(if scope toc
 	  (let ((outer-tag (if (org-html--html5-fancy-p info)
 			       "nav"
 			     "div")))
-	    (concat (format "<%s id=\"table-of-contents\">\n" outer-tag)
+	    (concat (format "<%s id=\"table-of-contents\" role=\"doc-toc\">\n" outer-tag)
 		    (let ((top-level (plist-get info :html-toplevel-hlevel)))
 		      (format "<h%d>%s</h%d>\n"
 			      top-level
@@ -2601,7 +2595,7 @@ (defun org-html-footnote-reference (footnote-reference _contents info)
      (format
       (plist-get info :html-footnote-format)
       (org-html--anchor
-       id n (format " class=\"footref\" href=\"#fn.%d\"" n) info)))))
+       id n (format " class=\"footref\" href=\"#fn.%d\" role=\"doc-backlink\"" n) info)))))
 
 ;;;; Headline
 
-- 
2.31.1


                 reply	other threads:[~2021-06-06 18:03 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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87pmwy50sh.fsf@gmail.com \
    --to=tecosaur@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: [PATCH] html export: remove W3C warning, improve accessibility' \
    /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

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).