瀏覽代碼

Merge branch 'fix-latex-internal-links'

Conflicts:
	lisp/ChangeLog
Carsten Dominik 16 年之前
父節點
當前提交
d6542dba1a
共有 3 個文件被更改,包括 53 次插入29 次删除
  1. 10 0
      lisp/ChangeLog
  2. 21 18
      lisp/org-exp.el
  3. 22 11
      lisp/org-export-latex.el

+ 10 - 0
lisp/ChangeLog

@@ -3,6 +3,16 @@
 	* org.el (org-edit-fixed-width-region): Exclude final newline from
 	picture area.
 
+	* org-export-latex.el (org-export-latex-subcontent): Add labels to
+	sections, to make internal links work.
+	(org-export-latex-fontify-headline): Do not remove all text
+	properties, to make sure that target properties survive this
+	process.
+
+	* org-exp.el (org-export-preprocess-string): Change sequence of
+	modifications, to make sure links are prepared before the LaTeX
+	conversions do happen.
+
 2008-10-09  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org-attach.el (org-attach-delete-all): Renamed from

+ 21 - 18
lisp/org-exp.el

@@ -1456,6 +1456,27 @@ on this string to produce the exported version."
       ;; Remove comment environment and comment subtrees
       (org-export-remove-comment-blocks-and-subtrees)
 
+
+      ;; Find matches for radio targets and turn them into internal links
+      (org-export-mark-radio-links)
+
+      ;; Find all links that contain a newline and put them into a single line
+      (org-export-concatenate-multiline-links)
+
+      ;; Normalize links: Convert angle and plain links into bracket links
+      ;; and expand link abbreviations
+      (org-export-normalize-links)
+
+      ;; Find all internal links.  If they have a fuzzy match (i.e. not
+      ;; a *dedicated* target match, let the link  point to the
+      ;; corresponding section.
+      (org-export-target-internal-links target-alist)
+
+      ;; Find multiline emphasis and put them into single line
+      (when (plist-get parameters :emph-multiline)
+	(org-export-concatenate-multiline-emphasis))
+
+
       ;; Remove special table lines
       (when org-export-table-remove-special-lines
 	(org-export-remove-special-table-lines))
@@ -1476,24 +1497,6 @@ on this string to produce the exported version."
       ;; Remove or replace comments
       (org-export-handle-comments (plist-get parameters :comments))
 
-      ;; Find matches for radio targets and turn them into internal links
-      (org-export-mark-radio-links)
-
-      ;; Find all links that contain a newline and put them into a single line
-      (org-export-concatenate-multiline-links)
-
-      ;; Normalize links: Convert angle and plain links into bracket links
-      ;; and expand link abbreviations
-      (org-export-normalize-links)
-
-      ;; Find all internal links.  If they have a fuzzy match (i.e. not
-      ;; a *dedicated* target match, let the link  point to the
-      ;; corresponding section.
-      (org-export-target-internal-links target-alist)
-
-      ;; Find multiline emphasis and put them into single line
-      (when (plist-get parameters :emph-multiline)
-	(org-export-concatenate-multiline-emphasis))
 
       (setq rtn (buffer-string)))
     (kill-buffer " org-mode-tmp")

+ 22 - 11
lisp/org-export-latex.el

@@ -543,31 +543,36 @@ and its content."
 (defun org-export-latex-subcontent (subcontent num)
   "Export each cell of SUBCONTENT to LaTeX.
 If NUM, export sections as numerical sections."
-  (let ((heading (org-export-latex-fontify-headline
-		  (cdr (assoc 'heading subcontent))))
-	(level (- (cdr (assoc 'level subcontent))
-		  org-export-latex-add-level))
-	(occur (number-to-string (cdr (assoc 'occur subcontent))))
-	(content (cdr (assoc 'content subcontent)))
-	(subcontent (cadr (assoc 'subcontent subcontent))))
+  (let* ((heading (org-export-latex-fontify-headline
+		   (cdr (assoc 'heading subcontent))))
+	 (level (- (cdr (assoc 'level subcontent))
+		   org-export-latex-add-level))
+	 (occur (number-to-string (cdr (assoc 'occur subcontent))))
+	 (content (cdr (assoc 'content subcontent)))
+	 (subcontent (cadr (assoc 'subcontent subcontent)))
+	 (label (org-get-text-property-any 0 'target heading)))
     (cond
      ;; Normal conversion
      ((<= level org-export-latex-sectioning-depth)
       (let ((sec (nth (1- level) org-export-latex-sectioning)))
 	(insert (format (if num (car sec) (cdr sec)) heading) "\n"))
+      (when label (insert (format "\\label{%s}\n" label)))
       (insert (org-export-latex-content content))
       (cond ((stringp subcontent) (insert subcontent))
 	    ((listp subcontent) (org-export-latex-sub subcontent))))
      ;; At a level under the hl option: we can drop this subsection
      ((> level org-export-latex-sectioning-depth)
       (cond ((eq org-export-latex-low-levels 'description)
-	     (insert (format "\\begin{description}\n\n\\item[%s]\n\n" heading))
+	     (insert (format "\\begin{description}\n\n\\item[%s]%s\n\n"
+			     heading
+			     (if label (format "\\label{%s}" label) "")))
 	     (insert (org-export-latex-content content))
 	     (cond ((stringp subcontent) (insert subcontent))
 		   ((listp subcontent) (org-export-latex-sub subcontent)))
 	     (insert "\\end{description}\n"))
 	    ((stringp org-export-latex-low-levels)
 	     (insert (format org-export-latex-low-levels heading) "\n")
+	     (when label (insert (format "\\label{%s}\n" label)))
 	     (insert (org-export-latex-content content))
 	     (cond ((stringp subcontent) (insert subcontent))
 		   ((listp subcontent) (org-export-latex-sub subcontent)))))))))
@@ -767,7 +772,8 @@ links, keywords, lists, tables, fixed-width"
     (org-export-latex-special-chars
      (plist-get org-export-latex-options-plist :sub-superscript))
     (org-export-latex-links)
-    (org-trim (buffer-substring-no-properties (point-min) (point-max)))))
+;    (org-trim (buffer-substring-no-properties (point-min) (point-max)))))
+    (org-trim (buffer-string))))
 
 (defun org-export-latex-quotation-marks ()
   "Export quotation marks depending on language conventions."
@@ -1069,7 +1075,11 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
 			      ;; image option should be set be a comment line
 			      org-export-latex-image-default-option
 			      (expand-file-name raw-path))))
-	     (radiop (insert (format "\\hyperref[%s]{%s}" raw-path desc)))
+	     (radiop (insert (format "\\hyperref[%s]{%s}"
+				     (org-solidify-link-text raw-path) desc)))
+	     ((not type)
+	      (insert (format "\\hyperref[%s]{%s}"
+			      (org-solidify-link-text raw-path) desc)))
 	     (path (insert (format "\\href{%s}{%s}" path desc)))
 	     (t (insert "\\texttt{" desc "}")))))))
 
@@ -1140,7 +1150,8 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
 		  ">>>?\\((INVISIBLE)\\)?") nil t)
     (replace-match
      (org-export-latex-protect-string
-      (format "\\label{%s}%s"(match-string 1)
+      (format "\\label{%s}%s" (save-match-data (org-solidify-link-text
+						(match-string 1)))
 	      (if (match-string 2) "" (match-string 1)))) t t))
 
   ;; Delete @<...> constructs