From 14b093275fafd44f617a35a9ed6a0ef326ee994e Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Sat, 7 Jul 2012 15:10:42 +0530 Subject: [PATCH] org-e-html/org-e-odt: Handle links to headlines created with C-c C-l --- contrib/lisp/org-e-html.el | 30 ++++++++++++++++-------------- contrib/lisp/org-e-odt.el | 29 +++++++++++++++++------------ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/contrib/lisp/org-e-html.el b/contrib/lisp/org-e-html.el index 3c122273d..fd998eea1 100644 --- a/contrib/lisp/org-e-html.el +++ b/contrib/lisp/org-e-html.el @@ -2548,21 +2548,23 @@ INFO is a plist holding contextual information. See (org-export-get-headline-number destination info) "-"))) (t (error "Shouldn't reach here")))) + ;; What description to use? (desc - ;; What description to use? - (cond - ;; Case 1: Link already has a description. Use it. - (desc desc) - ;; Case 2: Link has no description and headline is - ;; numbered. Use the section number. - ((org-export-numbered-headline-p destination info) - (mapconcat 'number-to-string - (org-export-get-headline-number - destination info) ".")) - ;; Case 3: Link has no description and headline is - ;; un-numbered. Use the headline title. - (t (org-export-data - (org-element-property :title destination) info))))) + ;; Case 1: Headline is numbered and LINK has no + ;; description or LINK's description matches + ;; headline's title. Display section number. + (if (and (org-export-numbered-headline-p destination info) + (or (not desc) + (string= desc (org-element-property + :raw-value destination)))) + (mapconcat 'number-to-string + (org-export-get-headline-number + destination info) ".") + ;; Case 2: Either the headline is un-numbered or + ;; LINK has a custom description. Display LINK's + ;; description or headline's title. + (or desc (org-export-data (org-element-property + :title destination) info))))) (format "%s" (org-solidify-link-text href) attributes desc))) ;; Fuzzy link points to a target. Do as above. diff --git a/contrib/lisp/org-e-odt.el b/contrib/lisp/org-e-odt.el index 549e82b6f..4a3c75a8d 100644 --- a/contrib/lisp/org-e-odt.el +++ b/contrib/lisp/org-e-odt.el @@ -368,7 +368,7 @@ new entry in `org-e-odt-automatic-styles'. Return (OBJECT-NAME (when (numberp desc) (setq desc (format "%d" desc) xref-format "number")) (when (listp desc) - (setq desc (mapconcat 'identity desc ".") xref-format "chapter")) + (setq desc (mapconcat 'number-to-string desc ".") xref-format "chapter")) (setq href (concat org-e-odt-bookmark-prefix href)) (org-e-odt-format-tags-simple '("" . @@ -3321,21 +3321,26 @@ INFO is a plist holding contextual information. See 'italic)) ;; Fuzzy link points to an invisible target. (keyword nil) - ;; LINK points to an headline. If headlines are numbered - ;; and the link has no description, display headline's - ;; number. Otherwise, display description or headline's - ;; title. + ;; LINK points to an headline. Check if LINK should display + ;; section numbers. (headline (let* ((headline-no (org-export-get-headline-number destination info)) (label (format "sec-%s" (mapconcat 'number-to-string headline-no "-"))) - (section-no (mapconcat 'number-to-string headline-no "."))) - (setq desc - (cond - (desc desc) - ((plist-get info :section-numbers) section-no) - (t (org-export-data - (org-element-property :title destination) info)))) + (desc + ;; Case 1: Headline is numbered and LINK has no + ;; description or LINK's description matches + ;; headline's title. Display section number. + (if (and (org-export-numbered-headline-p destination info) + (or (not desc) + (string= desc (org-element-property + :raw-value destination)))) + headline-no + ;; Case 2: Either the headline is un-numbered or + ;; LINK has a custom description. Display LINK's + ;; description or headline's title. + (or desc (org-export-data (org-element-property + :title destination) info))))) (org-e-odt-format-internal-link desc label))) ;; Fuzzy link points to a target. Do as above. (otherwise