emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-faq: Invalid XHTML
@ 2011-01-10 22:01 Jambunathan K
  2011-01-29 14:30 ` David Maus
  0 siblings, 1 reply; 4+ messages in thread
From: Jambunathan K @ 2011-01-10 22:01 UTC (permalink / raw)
  To: emacs-orgmode


There are 16 errors while validating org-faq page.

http://validator.w3.org/check?uri=http%3A%2F%2Forgmode.org%2Fworg%2Forg-faq.html&charset=%28detect+automatically%29&doctype=Inline&group=0

Can such errors be not caught as soon as it happens?

Jambunathan K.

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

* Re: org-faq: Invalid XHTML
  2011-01-10 22:01 org-faq: Invalid XHTML Jambunathan K
@ 2011-01-29 14:30 ` David Maus
  2011-01-31 18:36   ` [Accepted] " Bastien Guerry
  2011-01-31 18:44   ` Bastien
  0 siblings, 2 replies; 4+ messages in thread
From: David Maus @ 2011-01-29 14:30 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 534 bytes --]

At Tue, 11 Jan 2011 03:31:11 +0530,
Jambunathan K wrote:
>
>
> There are 16 errors while validating org-faq page.
>
> http://validator.w3.org/check?uri=http%3A%2F%2Forgmode.org%2Fworg%2Forg-faq.html&charset=%28detect+automatically%29&doctype=Inline&group=0
>
> Can such errors be not caught as soon as it happens?

Attached patch fixes a glitch in Org's HTML export and mitigates the
problem of invalid id and name attributes.

Best,
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.1.2: 0001-Create-proper-id-and-name-attribute-values.patch --]
[-- Type: text/plain, Size: 4405 bytes --]

From 7d3072bec82934499d463a076488dc7b36192756 Mon Sep 17 00:00:00 2001
From: David Maus <dmaus@ictsoc.de>
Date: Sat, 29 Jan 2011 15:19:53 +0100
Subject: [PATCH] Create proper id and name attribute values

* org-html.el (org-export-as-html)
(org-export-html-format-image, org-format-org-table-html)
(org-html-level-start): Solidify link targets.
* org-exp.el (org-solidify-link-text): Use better regexp and replace
string for id attributes.

This fixes a problem with HTML export reported by Jambunathan K
<kjambunathan <at> gmail.com>.

The regexp of invalid characters in `org-solidify-link-text' is
oriented towards the xml:id 1.0 specification
(cf. http://www.w3.org/TR/xml-id/).
---
 lisp/org-exp.el  |    2 +-
 lisp/org-html.el |   17 +++++++++--------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index a055bac..97f17e5 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1971,7 +1971,7 @@ can work correctly."
     (let* ((rtn
 	    (mapconcat
 	     'identity
-	     (org-split-string s "[ \t\r\n]+") "=="))
+	     (org-split-string s "[^a-zA-Z0-9_\\.-]+") "--"))
 	   (a (assoc rtn alist)))
       (or (cdr a) rtn))))
 
diff --git a/lisp/org-html.el b/lisp/org-html.el
index 9a5d225..8faf60f 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1150,7 +1150,7 @@ lang=\"%s\" xml:lang=\"%s\">
 					 (setq href
 					       (replace-regexp-in-string
 						"\\." "_" (format "sec-%s" snumber)))
-					 (setq href (or (cdr (assoc href org-export-preferred-target-alist)) href))
+					 (setq href (org-solidify-link-text (or (cdr (assoc href org-export-preferred-target-alist)) href)))
 					 (push
 					  (format
 					   (if todo
@@ -1814,7 +1814,7 @@ lang=\"%s\" xml:lang=\"%s\">
 	    (format "%s<div %sclass=\"figure\">
 <p>"
 		    (if org-par-open "</p>\n" "")
-		    (if label (format "id=\"%s\" " label) "")))
+		    (if label (format "id=\"%s\" " (org-solidify-link-text label)) "")))
 	(format "<img src=\"%s\"%s />"
 		src
 		(if (string-match "\\<alt=" (or attr ""))
@@ -1999,7 +1999,7 @@ for formatting.  This is required for the DocBook exporter."
       ;; DocBook document, we want to always include the caption to make
       ;; DocBook XML file valid.
       (push (format "<caption>%s</caption>" (or caption "")) html)
-      (when label (push (format "<a name=\"%s\" id=\"%s\"></a>" label label)
+      (when label (push (format "<a name=\"%s\" id=\"%s\"></a>" (org-solidify-link-text label) (org-solidify-link-text label))
 			html))
       (push html-table-tag html))
     (setq html (mapcar
@@ -2327,7 +2327,8 @@ When TITLE is nil, just close all open levels."
     (setq extra-targets (remove (or preferred target) extra-targets))
     (setq extra-targets
 	  (mapconcat (lambda (x)
-		       (if (org-uuidgen-p x) (setq x (concat "ID-" x)))
+		       (setq x (org-solidify-link-text
+				(if (org-uuidgen-p x) (concat "ID-" x) x)))
 		       (format "<a name=\"%s\" id=\"%s\"></a>"
 			       x x))
 		     extra-targets
@@ -2363,13 +2364,13 @@ When TITLE is nil, just close all open levels."
 		(progn
 		  (org-close-li)
 		  (if target
-		      (insert (format "<li id=\"%s\">" (or preferred target))
+		      (insert (format "<li id=\"%s\">" (org-solidify-link-text (or preferred target)))
 			      extra-targets title "<br/>\n")
 		    (insert "<li>" title "<br/>\n")))
 	      (aset org-levels-open (1- level) t)
 	      (org-close-par-maybe)
 	      (if target
-		  (insert (format "<ul>\n<li id=\"%s\">" (or preferred target))
+		  (insert (format "<ul>\n<li id=\"%s\">" (org-solidify-link-text (or preferred target)))
 			  extra-targets title "<br/>\n")
 		(insert "<ul>\n<li>" title "<br/>\n"))))
 	(aset org-levels-open (1- level) t)
@@ -2383,8 +2384,8 @@ When TITLE is nil, just close all open levels."
 			 " " title)))
 	(unless (= head-count 1) (insert "\n</div>\n"))
 	(setq href (cdr (assoc (concat "sec-" snu) org-export-preferred-target-alist)))
-	(setq suffix (or href snu))
-	(setq href (or href (concat "sec-" snu)))
+	(setq suffix (org-solidify-link-text (or href snu)))
+	(setq href (org-solidify-link-text (or href (concat "sec-" snu))))
 	(insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d%s\">\n<h%d id=\"%s\">%s%s</h%d>\n<div class=\"outline-text-%d\" id=\"text-%s\">\n"
 			suffix level (if extra-class (concat " " extra-class) "")
 			level href
-- 
1.7.2.3


[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* [Accepted] org-faq: Invalid XHTML
  2011-01-29 14:30 ` David Maus
@ 2011-01-31 18:36   ` Bastien Guerry
  2011-01-31 18:44   ` Bastien
  1 sibling, 0 replies; 4+ messages in thread
From: Bastien Guerry @ 2011-01-31 18:36 UTC (permalink / raw)
  To: emacs-orgmode

Patch 563 (http://patchwork.newartisans.com/patch/563/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C87lj23eqa7.wl%25dmaus%40ictsoc.de%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [Orgmode] org-faq: Invalid XHTML
> Date: Sat, 29 Jan 2011 19:30:08 -0000
> From: David Maus <dmaus@ictsoc.de>
> X-Patchwork-Id: 563
> Message-Id: <87lj23eqa7.wl%dmaus@ictsoc.de>
> To: Jambunathan K <kjambunathan@gmail.com>
> Cc: emacs-orgmode@gnu.org
> 
> At Tue, 11 Jan 2011 03:31:11 +0530,
> Jambunathan K wrote:
> >
> >
> > There are 16 errors while validating org-faq page.
> >
> > http://validator.w3.org/check?uri=http%3A%2F%2Forgmode.org%2Fworg%2Forg-faq.html&charset=%28detect+automatically%29&doctype=Inline&group=0
> >
> > Can such errors be not caught as soon as it happens?
> 
> Attached patch fixes a glitch in Org's HTML export and mitigates the
> problem of invalid id and name attributes.
> 
> Best,
>   -- David
> 
> ---
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de
> >From 7d3072bec82934499d463a076488dc7b36192756 Mon Sep 17 00:00:00 2001
> From: David Maus <dmaus@ictsoc.de>
> Date: Sat, 29 Jan 2011 15:19:53 +0100
> Subject: [PATCH] Create proper id and name attribute values
> 
> * org-html.el (org-export-as-html)
> (org-export-html-format-image, org-format-org-table-html)
> (org-html-level-start): Solidify link targets.
> * org-exp.el (org-solidify-link-text): Use better regexp and replace
> string for id attributes.
> 
> This fixes a problem with HTML export reported by Jambunathan K
> <kjambunathan <at> gmail.com>.
> 
> The regexp of invalid characters in `org-solidify-link-text' is
> oriented towards the xml:id 1.0 specification
> (cf. http://www.w3.org/TR/xml-id/).
> ---
>  lisp/org-exp.el  |    2 +-
>  lisp/org-html.el |   17 +++++++++--------
>  2 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/lisp/org-exp.el b/lisp/org-exp.el
> index a055bac..97f17e5 100644
> --- a/lisp/org-exp.el
> +++ b/lisp/org-exp.el
> @@ -1971,7 +1971,7 @@ can work correctly."
>      (let* ((rtn
>  	    (mapconcat
>  	     'identity
> -	     (org-split-string s "[ \t\r\n]+") "=="))
> +	     (org-split-string s "[^a-zA-Z0-9_\\.-]+") "--"))
>  	   (a (assoc rtn alist)))
>        (or (cdr a) rtn))))
>  
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index 9a5d225..8faf60f 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -1150,7 +1150,7 @@ lang=\"%s\" xml:lang=\"%s\">
>  					 (setq href
>  					       (replace-regexp-in-string
>  						"\\." "_" (format "sec-%s" snumber)))
> -					 (setq href (or (cdr (assoc href org-export-preferred-target-alist)) href))
> +					 (setq href (org-solidify-link-text (or (cdr (assoc href org-export-preferred-target-alist)) href)))
>  					 (push
>  					  (format
>  					   (if todo
> @@ -1814,7 +1814,7 @@ lang=\"%s\" xml:lang=\"%s\">
>  	    (format "%s<div %sclass=\"figure\">
>  <p>"
>  		    (if org-par-open "</p>\n" "")
> -		    (if label (format "id=\"%s\" " label) "")))
> +		    (if label (format "id=\"%s\" " (org-solidify-link-text label)) "")))
>  	(format "<img src=\"%s\"%s />"
>  		src
>  		(if (string-match "\\<alt=" (or attr ""))
> @@ -1999,7 +1999,7 @@ for formatting.  This is required for the DocBook exporter."
>        ;; DocBook document, we want to always include the caption to make
>        ;; DocBook XML file valid.
>        (push (format "<caption>%s</caption>" (or caption "")) html)
> -      (when label (push (format "<a name=\"%s\" id=\"%s\"></a>" label label)
> +      (when label (push (format "<a name=\"%s\" id=\"%s\"></a>" (org-solidify-link-text label) (org-solidify-link-text label))
>  			html))
>        (push html-table-tag html))
>      (setq html (mapcar
> @@ -2327,7 +2327,8 @@ When TITLE is nil, just close all open levels."
>      (setq extra-targets (remove (or preferred target) extra-targets))
>      (setq extra-targets
>  	  (mapconcat (lambda (x)
> -		       (if (org-uuidgen-p x) (setq x (concat "ID-" x)))
> +		       (setq x (org-solidify-link-text
> +				(if (org-uuidgen-p x) (concat "ID-" x) x)))
>  		       (format "<a name=\"%s\" id=\"%s\"></a>"
>  			       x x))
>  		     extra-targets
> @@ -2363,13 +2364,13 @@ When TITLE is nil, just close all open levels."
>  		(progn
>  		  (org-close-li)
>  		  (if target
> -		      (insert (format "<li id=\"%s\">" (or preferred target))
> +		      (insert (format "<li id=\"%s\">" (org-solidify-link-text (or preferred target)))
>  			      extra-targets title "<br/>\n")
>  		    (insert "<li>" title "<br/>\n")))
>  	      (aset org-levels-open (1- level) t)
>  	      (org-close-par-maybe)
>  	      (if target
> -		  (insert (format "<ul>\n<li id=\"%s\">" (or preferred target))
> +		  (insert (format "<ul>\n<li id=\"%s\">" (org-solidify-link-text (or preferred target)))
>  			  extra-targets title "<br/>\n")
>  		(insert "<ul>\n<li>" title "<br/>\n"))))
>  	(aset org-levels-open (1- level) t)
> @@ -2383,8 +2384,8 @@ When TITLE is nil, just close all open levels."
>  			 " " title)))
>  	(unless (= head-count 1) (insert "\n</div>\n"))
>  	(setq href (cdr (assoc (concat "sec-" snu) org-export-preferred-target-alist)))
> -	(setq suffix (or href snu))
> -	(setq href (or href (concat "sec-" snu)))
> +	(setq suffix (org-solidify-link-text (or href snu)))
> +	(setq href (org-solidify-link-text (or href (concat "sec-" snu))))
>  	(insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d%s\">\n<h%d id=\"%s\">%s%s</h%d>\n<div class=\"outline-text-%d\" id=\"text-%s\">\n"
>  			suffix level (if extra-class (concat " " extra-class) "")
>  			level href
> 

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

* Re: org-faq: Invalid XHTML
  2011-01-29 14:30 ` David Maus
  2011-01-31 18:36   ` [Accepted] " Bastien Guerry
@ 2011-01-31 18:44   ` Bastien
  1 sibling, 0 replies; 4+ messages in thread
From: Bastien @ 2011-01-31 18:44 UTC (permalink / raw)
  To: David Maus; +Cc: emacs-orgmode, Jambunathan K

David Maus <dmaus@ictsoc.de> writes:

> At Tue, 11 Jan 2011 03:31:11 +0530,
> Jambunathan K wrote:
>>
>>
>> There are 16 errors while validating org-faq page.
>>
>> http://validator.w3.org/check?uri=http%3A%2F%2Forgmode.org%2Fworg%2Forg-faq.html&charset=%28detect+automatically%29&doctype=Inline&group=0
>>
>> Can such errors be not caught as soon as it happens?

Jambunathan: thanks for the report!

> Attached patch fixes a glitch in Org's HTML export and mitigates the
> problem of invalid id and name attributes.

David, thanks a lot for this patch.  It fixes quite a lot of problems.
I've also pushed a tiny fix to use <hr/> instead of <hr>.

-- 
 Bastien

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

end of thread, other threads:[~2011-01-31 18:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-10 22:01 org-faq: Invalid XHTML Jambunathan K
2011-01-29 14:30 ` David Maus
2011-01-31 18:36   ` [Accepted] " Bastien Guerry
2011-01-31 18:44   ` Bastien

Code repositories for project(s) associated with this public 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).