unofficial mirror of
 help / color / mirror / code / Atom feed
* [PATCH] html export: remove W3C warning, improve accessibility
@ 2021-06-06 18:02 Timothy
  0 siblings, 0 replies; only message in thread
From: Timothy @ 2021-06-06 18:02 UTC (permalink / raw)
  To: org-mode-email

[-- 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) :)


[-- 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 <>
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
 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
- 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)
-			     (format " class=\"footnum\" href=\"#fnr.%d\"" n)
+			     (format " class=\"footnum\" href=\"#fnr.%d\" role=\"doc-backlink\"" n)
 		    (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>"
@@ -2120,7 +2114,7 @@ (defun org-html-template (contents info)
 	  (if subtitle
 	       (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)
 	(if scope toc
 	  (let ((outer-tag (if (org-html--html5-fancy-p info)
-	    (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"
@@ -2601,7 +2595,7 @@ (defun org-html-footnote-reference (footnote-reference _contents info)
       (plist-get info :html-footnote-format)
-       id n (format " class=\"footref\" href=\"#fn.%d\"" n) info)))))
+       id n (format " class=\"footref\" href=\"#fn.%d\" role=\"doc-backlink\"" n) info)))))
 ;;;; Headline

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

only message in thread, other threads:[~2021-06-06 18:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-06 18:02 [PATCH] html export: remove W3C warning, improve accessibility Timothy

unofficial mirror of

This inbox may be cloned and mirrored by anyone:

	git clone --mirror orgmode/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 orgmode orgmode/ \
	public-inbox-index orgmode

Example config snippet for mirrors.
Newsgroups are available over NNTP:

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

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git