瀏覽代碼

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 年之前
父節點
當前提交
d8e4a35974
共有 4 個文件被更改,包括 21 次插入1 次删除
  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
 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
 
 *** PDF export of agenda views

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 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
 	`cookies'.
 	(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)))
 	      (setq id-file (concat (file-name-sans-extension id-file)
 				    "." 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 ">"
 				(org-export-html-format-desc desc)
 				"</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)))
 	 (extra-targets
 	  (mapconcat (lambda (x)
+		       (if (org-uuidgen-p x) (setq x (concat "ID-" x)))
 		       (format "<a name=\"%s\" id=\"%s\"></a>"
 			       x x))
 		     (cdr (assoc target org-export-target-aliases))

+ 4 - 0
lisp/org.el

@@ -14644,6 +14644,10 @@ and end of string."
 		    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 ()
   "Return a list of contexts of the current cursor position.
 If several contexts apply, all are returned.