Forráskód Böngészése

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.
Carsten Dominik 16 éve
szülő
commit
6291ef8b7f
2 módosított fájl, 14 hozzáadás és 2 törlés
  1. 5 0
      lisp/ChangeLog
  2. 9 2
      lisp/org-exp.el

+ 5 - 0
lisp/ChangeLog

@@ -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

+ 9 - 2
lisp/org-exp.el

@@ -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>")))