From 7d3072bec82934499d463a076488dc7b36192756 Mon Sep 17 00:00:00 2001 From: David Maus 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 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

" (if org-par-open "

\n" "") - (if label (format "id=\"%s\" " label) ""))) + (if label (format "id=\"%s\" " (org-solidify-link-text label)) ""))) (format "" src (if (string-match "\\%s" (or caption "")) html) - (when label (push (format "" label label) + (when label (push (format "" (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 "" 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 "
  • " (or preferred target)) + (insert (format "
  • " (org-solidify-link-text (or preferred target))) extra-targets title "
    \n") (insert "
  • " title "
    \n"))) (aset org-levels-open (1- level) t) (org-close-par-maybe) (if target - (insert (format "
      \n
    • " (or preferred target)) + (insert (format "
        \n
      • " (org-solidify-link-text (or preferred target))) extra-targets title "
        \n") (insert "
          \n
        • " title "
          \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
  • \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
    \n%s%s\n
    \n" suffix level (if extra-class (concat " " extra-class) "") level href -- 1.7.2.3