Make sure that each <img> tag has an `alt' attribute.

XHTML validation requires hat each <img> tag does provide an
`alt' attribute.  This patch, based on a draft by Sebastian Rose, does
fix this.
This commit is contained in:
Carsten Dominik 2008-11-13 09:15:01 +01:00
parent 3b5007cd2b
commit 6291ef8b7f
2 changed files with 14 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2008-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-as-html): Make sure that each <img> tag
has an `alt' attribute, to ensure XHTML validation.
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
* org-publish.el (org-publish-attachment): Allow publishing to

View File

@ -3250,7 +3250,10 @@ lang=\"%s\" xml:lang=\"%s\">
(if (and (or (eq t org-export-html-inline-images)
(and org-export-html-inline-images (not descp)))
(org-file-image-p path))
(setq rpl (concat "<img src=\"" type ":" path "\"" attr "/>"))
(setq rpl (concat "<img src=\"" type ":" path "\""
(if (string-match "\\<alt=" attr)
attr (concat attr " alt=\"" path "\""))
"/>"))
(setq link (concat type ":" path))
(setq rpl (concat "<a href=\""
(org-export-html-format-href link)
@ -3308,7 +3311,11 @@ lang=\"%s\" xml:lang=\"%s\">
(or (eq t org-export-html-inline-images)
(and org-export-html-inline-images
(not descp))))
(concat "<img src=\"" thefile "\"" attr "/>")
(concat "<img src=\"" thefile "\""
(if (string-match "alt=" attr)
attr
(concat attr " alt=\""
thefile "\"")) "/>")
(concat "<a href=\"" thefile "\"" attr ">"
(org-export-html-format-desc desc)
"</a>")))