Merge branch 'hotfix-7.8.06' of orgmode.org:org-mode into hotfix-7.8.06

This commit is contained in:
Bastien Guerry 2012-03-21 01:12:08 +01:00
commit 431407cc27
2 changed files with 158 additions and 101 deletions

View File

@ -613,13 +613,14 @@ DocBook export
OpenDocument Text export OpenDocument Text export
* Pre-requisites for ODT export:: What packages ODT exporter relies on * Pre-requisites for ODT export:: What packages ODT exporter relies on
* ODT export commands:: How to invoke ODT export * ODT export commands:: How to invoke ODT export
* Extending ODT export:: How to produce @samp{doc}, @samp{pdf} files * Extending ODT export:: How to produce @samp{doc}, @samp{pdf} files
* Applying custom styles:: How to apply custom styles to the output * Applying custom styles:: How to apply custom styles to the output
* Links in ODT export:: How links will be interpreted and formatted * Links in ODT export:: How links will be interpreted and formatted
* Tables in ODT export:: How Tables are exported * Tables in ODT export:: How Tables are exported
* Images in ODT export:: How to insert images * Images in ODT export:: How to insert images
* Math formatting in ODT export:: How @LaTeX{} fragments are formatted * Math formatting in ODT export:: How @LaTeX{} fragments are formatted
* Labels and captions in ODT export:: How captions are rendered
* Literal examples in ODT export:: How source and example blocks are formatted * Literal examples in ODT export:: How source and example blocks are formatted
* Advanced topics in ODT export:: Read this if you are a power user * Advanced topics in ODT export:: Read this if you are a power user
@ -10799,13 +10800,14 @@ are compatible with LibreOffice 3.4.
@menu @menu
* Pre-requisites for ODT export:: What packages ODT exporter relies on * Pre-requisites for ODT export:: What packages ODT exporter relies on
* ODT export commands:: How to invoke ODT export * ODT export commands:: How to invoke ODT export
* Extending ODT export:: How to produce @samp{doc}, @samp{pdf} files * Extending ODT export:: How to produce @samp{doc}, @samp{pdf} files
* Applying custom styles:: How to apply custom styles to the output * Applying custom styles:: How to apply custom styles to the output
* Links in ODT export:: How links will be interpreted and formatted * Links in ODT export:: How links will be interpreted and formatted
* Tables in ODT export:: How Tables are exported * Tables in ODT export:: How Tables are exported
* Images in ODT export:: How to insert images * Images in ODT export:: How to insert images
* Math formatting in ODT export:: How @LaTeX{} fragments are formatted * Math formatting in ODT export:: How @LaTeX{} fragments are formatted
* Labels and captions in ODT export:: How captions are rendered
* Literal examples in ODT export:: How source and example blocks are formatted * Literal examples in ODT export:: How source and example blocks are formatted
* Advanced topics in ODT export:: Read this if you are a power user * Advanced topics in ODT export:: Read this if you are a power user
@end menu @end menu
@ -10966,8 +10968,15 @@ the factory settings.
@subsection Links in ODT export @subsection Links in ODT export
@cindex tables, in DocBook export @cindex tables, in DocBook export
The ODT exporter creates cross-references (aka bookmarks) for ODT exporter creates native cross-references for internal links. It creates
internal links. It creates Internet-style links for all other links. Internet-style links for all other links.
A link with no description and destined to a regular (un-itemized) outline
heading is replaced with a cross-reference and section number of the heading.
A @samp{\ref@{label@}}-style reference to an image, table etc. is replaced
with a cross-reference and sequence number of the labelled entity.
@xref{Labels and captions in ODT export}.
@node Tables in ODT export, Images in ODT export, Links in ODT export, OpenDocument Text export @node Tables in ODT export, Images in ODT export, Links in ODT export, OpenDocument Text export
@subsection Tables in ODT export @subsection Tables in ODT export
@ -11116,7 +11125,7 @@ To create an image that is anchored to a page, do the following:
[[./img.png]] [[./img.png]]
@end example @end example
@node Math formatting in ODT export, Literal examples in ODT export, Images in ODT export, OpenDocument Text export @node Math formatting in ODT export, Labels and captions in ODT export, Images in ODT export, OpenDocument Text export
@subsection Math formatting in ODT export @subsection Math formatting in ODT export
The ODT exporter has special support for handling math. The ODT exporter has special support for handling math.
@ -11210,34 +11219,69 @@ or
[[./equation.odf]] [[./equation.odf]]
@end example @end example
@node Literal examples in ODT export, Advanced topics in ODT export, Math formatting in ODT export, OpenDocument Text export @node Labels and captions in ODT export, Literal examples in ODT export, Math formatting in ODT export, OpenDocument Text export
@subsection Labels and captions in ODT export
You can label and caption various category of objects - an inline image, a
table, a @LaTeX{} fragment or a Math formula - using @code{#+LABEL} and
@code{#+CAPTION} lines. @xref{Images and tables}. ODT exporter enumerates
each labelled or captioned object of a given category separately. As a
result, each such object is assigned a sequence number based on order of it's
appearance in the Org file.
In the exported document, a user-provided caption is augmented with the
category and sequence number. Consider the following inline image in an Org
file.
@example
#+CAPTION: Bell curve
#+LABEL: fig:SED-HR4049
[[./img/a.png]]
@end example
It could be rendered as shown below in the exported document.
@example
Figure 2: Bell curve
@end example
@vindex org-export-odt-category-strings
You can modify the category component of the caption by customizing the
variable @code{org-export-odt-category-strings}. For example, to tag all
embedded images with the string @samp{Illustration} (instead of the default
@samp{Figure}) use the following setting.
@lisp
(setq org-export-odt-category-strings
'(("en" "Table" "Illustration" "Equation" "Equation")))
@end lisp
With this, previous image will be captioned as below in the exported
document.
@example
Illustration 2: Bell curve
@end example
@node Literal examples in ODT export, Advanced topics in ODT export, Labels and captions in ODT export, OpenDocument Text export
@subsection Literal examples in ODT export @subsection Literal examples in ODT export
Export of literal examples (@pxref{Literal examples}) with full fontification Export of literal examples (@pxref{Literal examples}) with full fontification
is supported. This feature is enabled by default and is activated is supported. Internally, the exporter relies on @file{htmlfontify.el} to
automatically if an enhanced version of @file{htmlfontify.el} is available in generate all style definitions needed for a fancy listing.@footnote{Your
the @code{load-path}.@footnote{The @file{htmlfontify.el} that ships with @file{htmlfontify.el} library must atleast be at Emacs 24.1 levels for
standard Emacs <= 24.1 has no support for ODT fontification. A fontification to be turned on.} The auto-generated styles have @samp{OrgSrc}
copy of the proposed version is available as an attachment to as prefix and inherit their color from the faces used by Emacs
@url{http://debbugs.gnu.org/cgi/bugreport.cgi?msg=5;filename=htmlfontify.el;att=9;bug=9914, @code{font-lock} library for the source language.
Emacs Bug #9914}.}
@vindex org-export-odt-fontify-srcblocks @vindex org-export-odt-fontify-srcblocks
If you prefer to use your own custom styles for fontification, you can do so
The character styles used for fontification of the literal blocks are by customizing the variable
auto-generated by the exporter in conjunction with @file{htmlfontify.el}
library and need not be included in the default @file{styles.xml} file.
These auto-generated styles have the @samp{OrgSrc} prefix and inherit their color
based on the face used by Emacs @code{font-lock} library.
@vindex org-export-odt-create-custom-styles-for-srcblocks
If you prefer to use your own custom styles for fontification and disable
their auto-generation altogether, you can do so by customizing the variable
@code{org-export-odt-create-custom-styles-for-srcblocks}. @code{org-export-odt-create-custom-styles-for-srcblocks}.
You can turn off fontification support for literal examples by customizing @vindex org-export-odt-create-custom-styles-for-srcblocks
the variable @code{org-export-odt-fontify-srcblocks}. You can turn off fontification of literal examples by customizing the
variable @code{org-export-odt-fontify-srcblocks}.
@node Advanced topics in ODT export, , Literal examples in ODT export, OpenDocument Text export @node Advanced topics in ODT export, , Literal examples in ODT export, OpenDocument Text export
@subsection Advanced topics in ODT export @subsection Advanced topics in ODT export
@ -11496,7 +11540,7 @@ the table that follows.
@end lisp @end lisp
@example @example
#+ATTR_ODT: TableWithHeaderRowAndColumn #+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
| Name | Phone | Age | | Name | Phone | Age |
| Peter | 1234 | 17 | | Peter | 1234 | 17 |
| Anna | 4321 | 25 | | Anna | 4321 | 25 |
@ -11601,9 +11645,9 @@ To define a table style, create an entry for the style in the variable
@end itemize @end itemize
For example, the entry below defines two different table styles For example, the entry below defines two different table styles
@samp{TableWithHeaderRowsAndColumns} and @samp{TableWithHeaderColumns} based @samp{TableWithHeaderRowAndColumn} and @samp{TableWithFirstRowandLastRow}
on the same template @samp{Custom}. The styles achieve their intended effect based on the same template @samp{Custom}. The styles achieve their intended
by selectively activating the individual cell styles in that template. effect by selectively activating the individual cell styles in that template.
@lisp @lisp
(setq org-export-odt-table-styles (setq org-export-odt-table-styles
@ -11623,7 +11667,7 @@ To do this, specify the table style created in step (2) as part of
the @code{ATTR_ODT} line as shown below. the @code{ATTR_ODT} line as shown below.
@example @example
#+ATTR_ODT: TableWithHeaderRowAndColumn #+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
| Name | Phone | Age | | Name | Phone | Age |
| Peter | 1234 | 17 | | Peter | 1234 | 17 |
| Anna | 4321 | 25 | | Anna | 4321 | 25 |

View File

@ -1669,6 +1669,7 @@ ATTR is a string of other attributes of the a element."
;; links to headlines ;; links to headlines
((and (string= type "") ((and (string= type "")
(or (not thefile) (string= thefile "")) (or (not thefile) (string= thefile ""))
(plist-get org-lparse-opt-plist :section-numbers)
(setq sec-frag fragment) (setq sec-frag fragment)
(org-find-text-property-in-string 'org-no-description fragment) (org-find-text-property-in-string 'org-no-description fragment)
(or (string-match "\\`sec\\(\\(-[0-9]+\\)+\\)" sec-frag) (or (string-match "\\`sec\\(\\(-[0-9]+\\)+\\)" sec-frag)
@ -2062,93 +2063,105 @@ specifiers - %e and %n. %e is replaced with the CATEGORY-NAME.
%n is replaced with SEQNO. See %n is replaced with SEQNO. See
`org-odt-format-label-reference'.") `org-odt-format-label-reference'.")
(defcustom org-export-odt-category-strings
'(("en" "Table" "Figure" "Equation" "Equation"))
"Specify category strings for various captionable entities.
Captionable entity can be one of a Table, an Embedded Image, a
LaTeX fragment (generated with dvipng) or a Math Formula.
For example, when `org-export-default-language' is \"en\", an
embedded image will be captioned as \"Figure 1: Orgmode Logo\".
If you want the images to be captioned instead as \"Illustration
1: Orgmode Logo\", then modify the entry for \"en\" as shown
below.
\(setq org-export-odt-category-strings
'\(\(\"en\" \"Table\" \"Illustration\"
\"Equation\" \"Equation\"\)\)\)"
:group 'org-export-odt
:version "24.1"
:type '(repeat (list (string :tag "Language tag")
(choice :tag "Table"
(const :tag "Use Default" nil)
(string :tag "Category string"))
(choice :tag "Figure"
(const :tag "Use Default" nil)
(string :tag "Category string"))
(choice :tag "Math Formula"
(const :tag "Use Default" nil)
(string :tag "Category string"))
(choice :tag "Dvipng Image"
(const :tag "Use Default" nil)
(string :tag "Category string")))))
(defvar org-odt-category-map-alist (defvar org-odt-category-map-alist
'(("__Table__" "Table" "value") '(("__Table__" "Table" "value")
("__Figure__" "Figure" "value") ("__Figure__" "Illustration" "value")
("__MathFormula__" "Equation" "text") ("__MathFormula__" "Text" "text")
("__DvipngImage__" "Equation" "value") ("__DvipngImage__" "Equation" "value")
;; ("__Table__" "Table" "category-and-value") ;; ("__Table__" "Table" "category-and-value")
;; ("__Figure__" "Figure" "category-and-value") ;; ("__Figure__" "Figure" "category-and-value")
;; ("__DvipngImage__" "Equation" "category-and-value") ;; ("__DvipngImage__" "Equation" "category-and-value")
) )
"Map a CATEGORY-HANDLE to CATEGORY-NAME and LABEL-STYLE. "Map a CATEGORY-HANDLE to OD-VARIABLE and LABEL-STYLE.
This is an alist where each element is of the form This is a list where each entry is of the form \\(CATEGORY-HANDLE
\\(CATEGORY-HANDLE CATEGORY-NAME LABEL-STYLE\\). CATEGORY_HANDLE OD-VARIABLE LABEL-STYLE\\). CATEGORY_HANDLE identifies the
could either be one of the internal handles (as seen above) or be captionable entity in question. OD-VARIABLE is the OpenDocument
derived from the \"#+LABEL:<label-name>\" specification. See sequence counter associated with the entity. These counters are
`org-export-odt-get-category-from-label'. CATEGORY-NAME and declared within
LABEL-STYLE are used for generating ODT labels. See \"<text:sequence-decls>...</text:sequence-decls>\" block of
`org-odt-label-styles'.") `org-export-odt-content-template-file'. LABEL-STYLE is a key
into `org-odt-label-styles' and specifies how a given entity
should be captioned and referenced.
(defvar org-export-odt-user-categories The position of a CATEGORY-HANDLE in this list is used as an
'("Illustration" "Table" "Text" "Drawing" "Equation" "Figure")) index in to per-language entry for
`org-export-odt-category-strings' to retrieve a CATEGORY-NAME.
(defvar org-export-odt-get-category-from-label nil This CATEGORY-NAME is then used for qualifying the user-specified
"Should category of label be inferred from label itself. captions on export.")
When this option is non-nil, a label is parsed in to two
component parts delimited by a \":\" (colon) as shown here -
#+LABEL:[CATEGORY-HANDLE:]EXTRA. The CATEGORY-HANDLE is mapped
to a CATEGORY-NAME and LABEL-STYLE using
`org-odt-category-map-alist'. (If no such map is provided and
CATEGORY-NAME is set to CATEGORY-HANDLE and LABEL-STYLE is set to
\"category-and-value\"). If CATEGORY-NAME so obtained is listed
under `org-export-odt-user-categories' then the user specified
styles are used. Otherwise styles as determined by the internal
CATEGORY-HANDLE is used. See
`org-odt-get-label-category-and-style' for details.")
(defun org-odt-get-label-category-and-style (label default-category)
"See `org-export-odt-get-category-from-label'."
(let ((default-category-map
(assoc default-category org-odt-category-map-alist))
user-category user-category-map category)
(cond
((not org-export-odt-get-category-from-label)
default-category-map)
((not (setq user-category
(save-match-data
(and (string-match "\\`\\(.*\\):.+" label)
(match-string 1 label)))))
default-category-map)
(t
(setq user-category-map
(or (assoc user-category org-odt-category-map-alist)
(list nil user-category "category-and-value"))
category (nth 1 user-category-map))
(if (member category org-export-odt-user-categories)
user-category-map
default-category-map)))))
(defun org-odt-add-label-definition (label default-category) (defun org-odt-add-label-definition (label default-category)
"Create an entry in `org-odt-entity-labels-alist' and return it." "Create an entry in `org-odt-entity-labels-alist' and return it."
(setq label (substring-no-properties label)) (let* ((label-props (assoc default-category org-odt-category-map-alist))
(let* ((label-props (org-odt-get-label-category-and-style ;; identify the sequence number
label default-category)) (counter (nth 1 label-props))
(category (nth 1 label-props)) (sequence-var (intern counter))
(counter category)
(label-style (nth 2 label-props))
(sequence-var (intern (mapconcat
'downcase
(org-split-string counter) "-")))
(seqno (1+ (or (plist-get org-odt-entity-counts-plist sequence-var) (seqno (1+ (or (plist-get org-odt-entity-counts-plist sequence-var)
0))) 0)))
(label-props (list label category seqno label-style))) ;; assign an internal label, if user has not provided one
(label (if label (substring-no-properties label)
(format "%s-%s" default-category seqno)))
;; identify label style
(label-style (nth 2 label-props))
;; grok language setting
(en-strings (assoc-default "en" org-export-odt-category-strings))
(lang (plist-get org-lparse-opt-plist :language))
(lang-strings (assoc-default lang org-export-odt-category-strings))
;; retrieve localized category sting
(pos (- (length org-odt-category-map-alist)
(length (memq label-props org-odt-category-map-alist))))
(category (or (nth pos lang-strings) (nth pos en-strings)))
(label-props (list label category counter seqno label-style)))
;; synchronize internal counters
(setq org-odt-entity-counts-plist (setq org-odt-entity-counts-plist
(plist-put org-odt-entity-counts-plist sequence-var seqno)) (plist-put org-odt-entity-counts-plist sequence-var seqno))
;; stash label properties for later retrieval
(push label-props org-odt-entity-labels-alist) (push label-props org-odt-entity-labels-alist)
label-props)) label-props))
(defun org-odt-format-label-definition (caption label category seqno label-style) (defun org-odt-format-label-definition (caption label category counter
seqno label-style)
(assert label) (assert label)
(format-spec (format-spec
(cadr (assoc-string label-style org-odt-label-styles t)) (cadr (assoc-string label-style org-odt-label-styles t))
`((?e . ,category) `((?e . ,category)
(?n . ,(org-odt-format-tags (?n . ,(org-odt-format-tags
'("<text:sequence text:ref-name=\"%s\" text:name=\"%s\" text:formula=\"ooow:%s+1\" style:num-format=\"1\">" . "</text:sequence>") '("<text:sequence text:ref-name=\"%s\" text:name=\"%s\" text:formula=\"ooow:%s+1\" style:num-format=\"1\">" . "</text:sequence>")
(format "%d" seqno) label category category)) (format "%d" seqno) label counter counter))
(?c . ,(or (and caption (concat ": " caption)) ""))))) (?c . ,(or (and caption (concat ": " caption)) "")))))
(defun org-odt-format-label-reference (label category seqno label-style) (defun org-odt-format-label-reference (label category counter
seqno label-style)
(assert label) (assert label)
(save-match-data (save-match-data
(let* ((fmt (cddr (assoc-string label-style org-odt-label-styles t))) (let* ((fmt (cddr (assoc-string label-style org-odt-label-styles t)))