1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-24 07:20:29 +00:00

org-e-odt.el: Add frame title and description to latex equations

This commit is contained in:
Jambunathan K 2012-12-16 02:06:04 +05:30 committed by Bastien Guerry
parent fddc312c29
commit 2b761ceb39

View File

@ -741,7 +741,7 @@ in order to mimic default behaviour:
;;;; Links ;;;; Links
(defcustom org-e-odt-inline-formula-rules (defcustom org-e-odt-inline-formula-rules
'(("file" . "\\.\\(mathml\\|mml\\)\\'")) '(("file" . "\\.\\(mathml\\|mml\\|odf\\)\\'"))
"Rules characterizing formula files that can be inlined into HTML. "Rules characterizing formula files that can be inlined into HTML.
A rule consists in an association whose key is the type of link A rule consists in an association whose key is the type of link
@ -996,7 +996,7 @@ See `org-e-odt--build-date-styles' for implementation details."
;;;; Frame ;;;; Frame
(defun org-e-odt--frame (text width height style &optional extra (defun org-e-odt--frame (text width height style &optional extra
anchor-type) anchor-type &rest title-and-desc)
(let ((frame-attrs (let ((frame-attrs
(concat (concat
(if width (format " svg:width=\"%0.2fcm\"" width) "") (if width (format " svg:width=\"%0.2fcm\"" width) "")
@ -1007,21 +1007,21 @@ See `org-e-odt--build-date-styles' for implementation details."
"\n<draw:frame draw:style-name=\"%s\"%s>\n%s\n</draw:frame>" "\n<draw:frame draw:style-name=\"%s\"%s>\n%s\n</draw:frame>"
style frame-attrs style frame-attrs
(concat text (concat text
(let ((title (get-text-property 0 :title text)) (let ((title (car title-and-desc))
(desc (get-text-property 0 :description text))) (desc (cadr title-and-desc)))
(concat (and title (concat (when title
(format "<svg:title>%s</svg:title>" (format "<svg:title>%s</svg:title>"
(org-e-odt--encode-plain-text title t))) (org-e-odt--encode-plain-text title t)))
(and desc (when desc
(format "<svg:desc>%s</svg:desc>" (format "<svg:desc>%s</svg:desc>"
(org-e-odt--encode-plain-text desc t))))))))) (org-e-odt--encode-plain-text desc t)))))))))
;;;; Library wrappers ;;;; Library wrappers
(defun org-e-odt--zip-extract (archive members target) (defun org-e-odt--zip-extract (archive members target)
(when (atom members) (setq members (list members))) (when (atom members) (setq members (list members)))
(mapc (lambda (archive member target) (mapc (lambda (member)
(require 'arc-mode) (require 'arc-mode)
(let* ((--quote-file-name (let* ((--quote-file-name
;; This is shamelessly stolen from `archive-zip-extract'. ;; This is shamelessly stolen from `archive-zip-extract'.
@ -2276,13 +2276,25 @@ used as a communication channel."
"paragraph" ; FIXME "paragraph" ; FIXME
)) ))
(width (car size)) (height (cdr size)) (width (car size)) (height (cdr size))
(embed-as (if (org-e-odt--standalone-link-p element info) "paragraph" (standalone-link-p (org-e-odt--standalone-link-p element info))
"as-char")) (embed-as (if standalone-link-p "paragraph" "as-char"))
(captions (org-e-odt-format-label element info 'definition)) (captions (org-e-odt-format-label element info 'definition))
(caption (car captions)) (short-caption (cdr captions)) (caption (car captions)) (short-caption (cdr captions))
(entity (concat (and caption "Captioned") embed-as "Image"))) (entity (concat (and caption "Captioned") embed-as "Image"))
;; Check if this link was created by LaTeX-to-PNG converter.
(replaces (org-element-property
:replaces (if (not standalone-link-p) element
(org-export-get-parent-element element))))
;; If yes, note down the type of the element - LaTeX Fragment
;; or LaTeX environment. It will go in to frame title.
(title (and replaces (capitalize
(symbol-name (org-element-type replaces)))))
;; If yes, note down it's contents. It will go in to frame
;; description. This quite useful for debugging.
(desc (and replaces (org-element-property :value replaces))))
(org-e-odt--render-image/formula entity href width height (org-e-odt--render-image/formula entity href width height
captions user-frame-params ))) captions user-frame-params title desc)))
;;;; Links :: Math formula ;;;; Links :: Math formula
@ -2308,13 +2320,29 @@ used as a communication channel."
" xlink:show=\"embed\" xlink:actuate=\"onLoad\"" " xlink:show=\"embed\" xlink:actuate=\"onLoad\""
(file-name-directory (org-e-odt--copy-formula-file full-src)))) (file-name-directory (org-e-odt--copy-formula-file full-src))))
(embed-as (if caption 'paragraph 'character)) (embed-as (if caption 'paragraph 'character))
(standalone-link-p (org-e-odt--standalone-link-p element info))
;; Check if this link was created by LaTeX-to-MathML
;; converter.
(replaces (org-element-property
:replaces (if (not standalone-link-p) element
(org-export-get-parent-element element))))
;; If yes, note down the type of the element - LaTeX Fragment
;; or LaTeX environment. It will go in to frame title.
(title (and replaces (capitalize
(symbol-name (org-element-type replaces)))))
;; If yes, note down it's contents. It will go in to frame
;; description. This quite useful for debugging.
(desc (and replaces (org-element-property :value replaces)))
width height) width height)
(cond (cond
((eq embed-as 'character) ((eq embed-as 'character)
(org-e-odt--render-image/formula "InlineFormula" href width height)) (org-e-odt--render-image/formula "InlineFormula" href width height
nil nil title desc))
(t (t
(let* ((equation (org-e-odt--render-image/formula (let* ((equation (org-e-odt--render-image/formula
"CaptionedDisplayFormula" href width height captions)) "CaptionedDisplayFormula" href width height
captions nil title desc))
(label (label
(let* ((org-e-odt-category-map-alist (let* ((org-e-odt-category-map-alist
'(("__MathFormula__" "Text" "math-label" "Equation" '(("__MathFormula__" "Text" "math-label" "Equation"
@ -2352,7 +2380,8 @@ used as a communication channel."
;;;; Targets ;;;; Targets
(defun org-e-odt--render-image/formula (cfg-key href width height &optional (defun org-e-odt--render-image/formula (cfg-key href width height &optional
captions user-frame-params) captions user-frame-params
&rest title-and-desc)
(let* ((frame-cfg-alist (let* ((frame-cfg-alist
;; Each element of this alist is of the form (CFG-HANDLE ;; Each element of this alist is of the form (CFG-HANDLE
;; INNER-FRAME-PARAMS OUTER-FRAME-PARAMS). ;; INNER-FRAME-PARAMS OUTER-FRAME-PARAMS).
@ -2426,7 +2455,8 @@ used as a communication channel."
((not caption) ((not caption)
;; Merge user frame params with that from configuration. ;; Merge user frame params with that from configuration.
(setq inner (funcall --merge-frame-params inner user)) (setq inner (funcall --merge-frame-params inner user))
(apply 'org-e-odt--frame href width height inner)) (apply 'org-e-odt--frame href width height
(append inner title-and-desc)))
;; Case 2: Image/Formula is captioned or labeled. ;; Case 2: Image/Formula is captioned or labeled.
;; There are two frames: The inner one surrounds the ;; There are two frames: The inner one surrounds the
;; image or formula. The outer one contains the ;; image or formula. The outer one contains the
@ -2446,7 +2476,8 @@ used as a communication channel."
(format "\n<text:p text:style-name=\"%s\">%s</text:p>" (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
"Illustration" "Illustration"
(concat (concat
(apply 'org-e-odt--frame href width height inner) (apply 'org-e-odt--frame href width height
(append inner title-and-desc))
caption)) caption))
width height outer))))) width height outer)))))