summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJambunathan K <kjambunathan@gmail.com>2012-03-20 13:32:23 +0530
committerJambunathan K <kjambunathan@gmail.com>2012-03-20 13:32:23 +0530
commit4120d6fcf741f04673e90133ee8fb98a879c8e1d (patch)
treec25bbf7aeabb5436dd85239fe220c22118920c54
parentc983bc24002f7e9c2cbd2ba244a51f1b735a2e4a (diff)
downloadorg-mode-4120d6fcf741f04673e90133ee8fb98a879c8e1d.tar.gz
org-odt.el: Render links to outline headings as section nos
* lisp/org-lparse.el (org-do-lparse): Make effective setting of `org-export-headline-levels' available to the ODT exporter. Also remove some stale comments. * lisp/org-odt.el (org-odt-format-link): Add support for generating cross-references to chapter numbers. (org-odt-format-org-link): Resolve links to outline headings as section numbers. This special case resolution kicks in only if the Org link has no description and the target outline is not listified i.e., it is at a level within `org-export-headline-levels'. Fix for the following request: http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg01035.html The above change is in conformity with the way links to headlines will be treated in new ODT exporter that will be built on top of Nicolas' org-element/org-export infrastructure.
-rw-r--r--lisp/org-lparse.el44
-rw-r--r--lisp/org-odt.el25
2 files changed, 25 insertions, 44 deletions
diff --git a/lisp/org-lparse.el b/lisp/org-lparse.el
index 8530757..c9669dd 100644
--- a/lisp/org-lparse.el
+++ b/lisp/org-lparse.el
@@ -809,6 +809,8 @@ version."
(setq umax-toc (if (integerp org-export-with-toc)
(min org-export-with-toc umax)
umax))
+ (setq org-lparse-opt-plist
+ (plist-put org-lparse-opt-plist :headline-levels umax))
(when (and org-export-with-toc (not body-only))
(setq lines (org-lparse-prepare-toc
@@ -845,48 +847,6 @@ version."
(org-lparse-end-environment 'fixedwidth))
(throw 'nextline nil))
- ;; Notes: The baseline version of org-html.el (git commit
- ;; 3d802e), while encountering a *line-long* protected text,
- ;; does one of the following two things based on the state
- ;; of the export buffer.
-
- ;; 1. If a paragraph element has just been opened and
- ;; contains only whitespace as content, insert the
- ;; protected text as part of the previous paragraph.
-
- ;; 2. If the paragraph element has already been opened and
- ;; contains some valid content insert the protected text
- ;; as part of the current paragraph.
-
- ;; I think --->
-
- ;; Scenario 1 mentioned above kicks in when a block of
- ;; protected text has to be inserted en bloc. For example,
- ;; this happens, when inserting an source or example block
- ;; or preformatted content enclosed in #+backend,
- ;; #+begin_backend ... #+end_backend)
-
- ;; Scenario 2 mentioned above kicks in when the protected
- ;; text is part of a running sentence. For example this
- ;; happens in the case of an *multiline* LaTeX equation that
- ;; needs to be inserted verbatim.
-
- ;; org-html.el in the master branch seems to do some
- ;; jugglery by moving paragraphs around. Inorder to make
- ;; these changes backend-agnostic introduce a new text
- ;; property org-native-text and impose the added semantics
- ;; that these protected blocks appear outside of a
- ;; conventional paragraph element.
- ;;
- ;; Extra Note: Check whether org-example and org-native-text
- ;; are entirely equivalent.
-
- ;; Fixes bug reported by Christian Moe concerning verbatim
- ;; LaTeX fragments.
- ;; on git commit 533ba3f90250a1f25f494c390d639ea6274f235c
- ;; http://repo.or.cz/w/org-mode/org-jambu.git/shortlog/refs/heads/staging
- ;; See http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01379.html
-
;; Native Text
(when (and (get-text-property 0 'org-native-text line)
;; Make sure it is the entire line that is protected
diff --git a/lisp/org-odt.el b/lisp/org-odt.el
index e291cf2..114988f 100644
--- a/lisp/org-odt.el
+++ b/lisp/org-odt.el
@@ -1253,10 +1253,13 @@ styles congruent with the ODF-1.2 specification."
(defun org-odt-format-link (desc href &optional attr)
(cond
((and (= (string-to-char href) ?#) (not org-odt-suppress-xref))
- (setq href (concat org-export-odt-bookmark-prefix (substring href 1)))
+ (setq href (substring href 1))
(let ((xref-format "text"))
(when (numberp desc)
(setq desc (format "%d" desc) xref-format "number"))
+ (when (listp desc)
+ (setq desc (mapconcat 'identity desc ".") xref-format "chapter"))
+ (setq href (concat org-export-odt-bookmark-prefix href))
(org-odt-format-tags
'("<text:bookmark-ref text:reference-format=\"%s\" text:ref-name=\"%s\">" .
"</text:bookmark-ref>")
@@ -1623,7 +1626,8 @@ ATTR is a string of other attributes of the a element."
(not fragment)))
(type (if (equal type-1 "id") "file" type-1))
(filename path)
- (thefile path))
+ (thefile path)
+ sec-frag sec-nos)
(cond
;; check for inlined images
((and (member type '("file"))
@@ -1639,6 +1643,7 @@ ATTR is a string of other attributes of the a element."
(org-odt-is-formula-link-p filename)
(or (not descp)))
(org-odt-format-inline-formula thefile))
+ ;; code references
((string= type "coderef")
(let* ((ref fragment)
(lineno-or-ref (cdr (assoc ref org-export-code-refs)))
@@ -1661,6 +1666,22 @@ ATTR is a string of other attributes of the a element."
(or desc "%s"))
lineno-or-ref))
(org-odt-format-link (org-xml-format-desc desc) href)))))
+ ;; links to headlines
+ ((and (string= type "")
+ (or (not thefile) (string= thefile ""))
+ (setq sec-frag fragment)
+ (org-find-text-property-in-string 'org-no-description fragment)
+ (or (string-match "\\`sec\\(\\(-[0-9]+\\)+\\)" sec-frag)
+ (and (setq sec-frag
+ (loop for alias in org-export-target-aliases do
+ (when (member fragment (cdr alias))
+ (return (car alias)))))
+ (string-match "\\`sec\\(\\(-[0-9]+\\)+\\)" sec-frag)))
+ (setq sec-nos (org-split-string (match-string 1 sec-frag) "-"))
+ (<= (length sec-nos) (plist-get org-lparse-opt-plist
+ :headline-levels)))
+ (let ((org-odt-suppress-xref nil))
+ (org-odt-format-link sec-nos (concat "#" sec-frag) attr)))
(t
(when (string= type "file")
(setq thefile