Browse Source

HTML Export: Make IDs valid

uuidgen ids may start with a number and therefore are not valid names
in HTML.  Therefore we now use and "ID-" prefix for such IDs when
exporting to HTML.
Carsten Dominik 16 years ago
parent
commit
d8e4a35974
4 changed files with 21 additions and 1 deletions
  1. 9 0
      ORGWEBPAGE/Changes.org
  2. 4 0
      lisp/ChangeLog
  3. 4 1
      lisp/org-exp.el
  4. 4 0
      lisp/org.el

+ 9 - 0
ORGWEBPAGE/Changes.org

@@ -26,6 +26,15 @@ with the =C-c a m= key for the corresponding agenda view.
 =C-c / T= will still work for now, but it is no longer advertised
 =C-c / T= will still work for now, but it is no longer advertised
 in the documentation and may go away at any time in the future.
 in the documentation and may go away at any time in the future.
 
 
+*** IDs in HTML have "ID-" prefix when generated by uuidgen
+
+=uuidgen= generates IDs that often start with a number, not a
+latter.  However, IDs and names in XHTML must start with a letter.
+Therefore, IDs in HTML files will now get an "ID-" prefix if they
+have been generated by uuidgen.  This means that id links from one
+file to another may stop working until all files have been
+exported again.
+
 ** Details
 ** Details
 
 
 *** PDF export of agenda views
 *** PDF export of agenda views

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2009-03-03  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-03-03  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
+	* org-exp.el (org-export-as-html): Use IDs in the correct way.
+
+	* org.el (org-uuidgen-p): New funtion.
+
 	* org-agenda.el (org-agenda-fontify-priorities): New default value
 	* org-agenda.el (org-agenda-fontify-priorities): New default value
 	`cookies'.
 	`cookies'.
 	(org-agenda-fontify-priorities): Renamed from
 	(org-agenda-fontify-priorities): Renamed from

+ 4 - 1
lisp/org-exp.el

@@ -3745,7 +3745,9 @@ lang=\"%s\" xml:lang=\"%s\">
 			     id-file (file-name-directory org-current-export-file)))
 			     id-file (file-name-directory org-current-export-file)))
 	      (setq id-file (concat (file-name-sans-extension id-file)
 	      (setq id-file (concat (file-name-sans-extension id-file)
 				    "." html-extension))
 				    "." html-extension))
-	      (setq rpl (concat "<a href=\"" id-file "#" path "\""
+	      (setq rpl (concat "<a href=\"" id-file "#"
+				(if (org-uuidgen-p path) "ID-")
+				path "\""
 				attr ">"
 				attr ">"
 				(org-export-html-format-desc desc)
 				(org-export-html-format-desc desc)
 				"</a>")))
 				"</a>")))
@@ -4738,6 +4740,7 @@ When TITLE is nil, just close all open levels."
   (let* ((target (and title (org-get-text-property-any 0 'target title)))
   (let* ((target (and title (org-get-text-property-any 0 'target title)))
 	 (extra-targets
 	 (extra-targets
 	  (mapconcat (lambda (x)
 	  (mapconcat (lambda (x)
+		       (if (org-uuidgen-p x) (setq x (concat "ID-" x)))
 		       (format "<a name=\"%s\" id=\"%s\"></a>"
 		       (format "<a name=\"%s\" id=\"%s\"></a>"
 			       x x))
 			       x x))
 		     (cdr (assoc target org-export-target-aliases))
 		     (cdr (assoc target org-export-target-aliases))

+ 4 - 0
lisp/org.el

@@ -14644,6 +14644,10 @@ and end of string."
 		    list)))
 		    list)))
     (nreverse list)))
     (nreverse list)))
 
 
+(defun org-uuidgen-p (s)
+  "Is S an ID created by UUIDGEN?"
+  (string-match "\\`[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{12\\}\\'" (downcase s)))
+
 (defun org-context ()
 (defun org-context ()
   "Return a list of contexts of the current cursor position.
   "Return a list of contexts of the current cursor position.
 If several contexts apply, all are returned.
 If several contexts apply, all are returned.