[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Open Document Exporter
From: |
Georg Lehner |
Subject: |
Re: [O] Open Document Exporter |
Date: |
Thu, 27 Jun 2013 02:19:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 |
On 06/25/2013 03:35 AM, Vikas Rawal wrote:
At the end of the export process I get the message:
content.xml changed on disk; really edit the buffer? (y, n, r or C-h)
Please type y, n or r; or ? for help
After typing 'y', I have to reconfirm with 'yes' and then with 'y' again to
get a valid export.
Any tips how to fix or avoid this?
You perhaps have content.xml open as a buffer in emacs. Close that
buffer, and you should be fine.
Vikas
The content.xml buffer gets created and modified by the exporter.
I have found at least one (and the more annoying) place in ox-odt.el,
where this happens.
Using the 'write-file function Instead of (save-buffer 0) resolved the
issue.
In the patch below there are the following "fixes" for ox-odt.el:
1. content.xml changed on disk message avoided
=============================
see: @@ -4092,7 +4111,9 @@
2. Internal cross references
================
By replacing 'OrgXref.' with '__RefHeading__' has prefix of internal
link labels, the cross
references show the target Heading Line when the mouse hovers over them.
The patch is rather brute force, but e.g. table captions and references
still show the
"original" behavior: The reference shows "Table" and the caption shows
the Table
number when hovering over them.
By replacing: text:reference-format=\"chapter\" with
text:reference-format=\"number\"
cross references show the real chapter number, not the internal
numbering. This
is e.g. different, when you decide to change the outline numbering
properties "Before"
and "After" from their defaults.
While looking at that I found out that some 'bookmarks' get generated
twice by the
exporter: once as "OrgXref.sec-n-m" and once as "sec-n-m", with n and m
beeing
the chapter and section numbers.
3. Search path for contributed style files
=======================
@@ -157,7 +157,7 @@
the search path for "git" based org-mode installations had one parent
directory level
too much (../).
4. LaTeX like definition lists
================
The rest of the patch deals with trying to make definition lists
- term :: definition
look as in LaTex and not as in HTML.
Caution! the patch is very quirky, it does not work with nested lists at
all.
It works fine with simple, short definitions though.
How to use it:
- create a text style named 'OrgDefinitionTerm' in your template file.
Bold text
is sufficient.
- create a paragraph style named 'OrgDefinitionItem' in your template file.
I made mine having a hanging indent of 2cm and one (1) tab-stop at 2.1cm.
What the patch does:
- The 'org-odt--translate-description-lists' filter is removed from the
filter stack,
so descriptive lists remain just descriptive lists (and do not get
split into descriptive-1
and descriptive-2 item pairs.
- When transcoding 'descriptive' items to ODT, the term is retrived,
typeset in bold,
and inserted in front of the 'contents' of the iterm, separated by a tab.
- in all "case" constructs where "descriptive-1" and "...-2" occurs, I
added "descriptive" too.
How *should* it work:
I guess the better solution would be to modify the
'org-odt--translate-description-lists' filter
in a way to produce the same effect on the parsed tree representation of
the document.
So nested definition lists would work.
Of course a customizable variable, or some per file/per subtree #+ODT
tag is needed to
switch on demand between the two representations.
Best Regards,
Georg Lehner
- - -
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index a76f7dd..c8b704c 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -86,7 +86,7 @@
:export-block "ODT"
:filters-alist '((:filter-parse-tree
. (org-odt--translate-latex-fragments
- org-odt--translate-description-lists
+ ;;org-odt--translate-description-lists
org-odt--translate-list-tables)))
:menu-entry
'(?o "Export to ODT"
@@ -157,7 +157,7 @@ and `org-odt-data-dir'.")
(eval-when-compile
(and (boundp 'org-odt-data-dir) org-odt-data-dir ; see make install
(expand-file-name "./styles/" org-odt-data-dir)))
- (expand-file-name "../../etc/styles/" org-odt-lib-dir) ; git
+ (expand-file-name "../etc/styles/" org-odt-lib-dir) ; git
(expand-file-name "./etc/styles/" org-odt-lib-dir) ; elpa
(expand-file-name "./org/" data-directory) ; system
)
@@ -201,7 +201,7 @@ version of org in use and is initialized from
from one of: org's own private git repository, GNU ELPA tar or
standard Emacs.")
-(defconst org-odt-bookmark-prefix "OrgXref.")
+(defconst org-odt-bookmark-prefix "__RefHeading__")
(defconst org-odt-manifest-file-entry-tag
"\n<manifest:file-entry manifest:media-type=\"%s\"
manifest:full-path=\"%s\"%s/>")
@@ -1064,9 +1064,9 @@ See `org-odt--build-date-styles' for
implementation details."
(defun org-odt--target (text id)
(if (not id) text
(concat
- (format "\n<text:bookmark-start text:name=\"OrgXref.%s\"/>" id)
+ (format "\n<text:bookmark-start text:name=\"__RefHeading__%s\"/>" id)
(format "\n<text:bookmark text:name=\"%s\"/>" id) text
- (format "\n<text:bookmark-end text:name=\"OrgXref.%s\"/>" id))))
+ (format "\n<text:bookmark-end text:name=\"__RefHeading__%s\"/>" id))))
;;;; Textbox
@@ -1997,19 +1997,36 @@ contextual information."
(concat (org-odt--checkbox item)
(org-export-data tag info))))))
(case type
- ((ordered unordered descriptive-1 descriptive-2)
- (format "\n<text:list-item>\n%s\n%s"
- contents
- (let* ((--element-has-a-table-p
- (function
- (lambda (element info)
- (loop for el in (org-element-contents element)
- thereis (eq (org-element-type el) 'table))))))
- (cond
- ((funcall --element-has-a-table-p item info)
- "</text:list-header>")
- (t "</text:list-item>")))))
- (t (error "Unknown list type: %S" type)))))
+ ((ordered unordered descriptive-1 descriptive-2 descriptive)
+ (case type
+ ((ordered unordered descriptive-1 descriptive-2)
+ (format "\n<text:list-item>\n%s\n%s"
+ contents
+ (let* ((--element-has-a-table-p
+ (function
+ (lambda (element info)
+ (loop for el in (org-element-contents element)
+ thereis (eq (org-element-type el) 'table))))))
+ (cond
+ ((funcall --element-has-a-table-p item info)
+ "</text:list-header>")
+ (t "</text:list-item>")))))
+ (descriptive
+ (format "\n<text:list-item>\n%s\n%s"
+ (replace-regexp-in-string
+ "^<text:p ?.*?>"
+ (format "<text:p
text:style-name=\"OrgDefinitionItem\"><text:span
text:style-name=\"OrgDefinitionTerm\">%s</text:span><text:tab/>" tag)
+ contents)
+ (let* ((--element-has-a-table-p
+ (function
+ (lambda (element info)
+ (loop for el in (org-element-contents element)
+ thereis (eq (org-element-type el) 'table))))))
+ (cond
+ ((funcall --element-has-a-table-p item info)
+ "</text:list-header>")
+ (t "</text:list-item>")))))
+ (t (error "Unknown list type: %S" type)))))))
;;;; Keyword
@@ -2723,7 +2740,7 @@ Return nil, otherwise."
return el)))
;; We found one.
(when headline
- (format "<text:bookmark-ref text:reference-format=\"chapter\"
text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+ (format "<text:bookmark-ref text:reference-format=\"number\"
text:ref-name=\"__RefHeading__%s\">%s</text:bookmark-ref>"
(org-export-solidify-link-text label)
(mapconcat 'number-to-string (org-export-get-headline-number
headline info) "."))))
@@ -2735,7 +2752,7 @@ Return nil, otherwise."
return el)))
;; We found one.
(when headline
- (format "<text:bookmark-ref text:reference-format=\"text\"
text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+ (format "<text:bookmark-ref text:reference-format=\"text\"
text:ref-name=\"__RefHeading__%s\">%s</text:bookmark-ref>"
(org-export-solidify-link-text label)
(let ((title (org-element-property :title headline)))
(org-export-data title info)))))
@@ -2781,7 +2798,7 @@ INFO is a plist holding contextual information. See
(let ((desc (org-export-data (org-element-contents destination)
info))
(href (org-export-solidify-link-text path)))
(format
- "<text:bookmark-ref text:reference-format=\"text\"
text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+ "<text:bookmark-ref text:reference-format=\"text\"
text:ref-name=\"__RefHeading__%s\">%s</text:bookmark-ref>"
href desc)))))
;; Links pointing to a headline: Find destination and build
;; appropriate referencing command.
@@ -2846,7 +2863,7 @@ INFO is a plist holding contextual information. See
(format
(org-export-get-coderef-format path desc)
(format
- "<text:bookmark-ref text:reference-format=\"number\"
text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+ "<text:bookmark-ref text:reference-format=\"number\"
text:ref-name=\"__RefHeading__%s\">%s</text:bookmark-ref>"
href line-no))))
;; Link type is handled by a special function.
((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
@@ -2920,6 +2937,7 @@ contextual information."
(case (org-element-property :type plain-list)
(ordered "OrgNumberedList")
(unordered "OrgBulletedList")
+ (descriptive "OrgDescriptionList")
(descriptive-1 "OrgDescriptionList")
(descriptive-2 "OrgDescriptionList"))
;; If top-level list, re-start numbering. Otherwise,
@@ -3559,6 +3577,7 @@ pertaining to indentation here."
(case (org-element-property :type el)
(ordered "OrgNumberedList")
(unordered "OrgBulletedList")
+ (descriptive "OrgDescriptionList")
(descriptive-1 "OrgDescriptionList")
(descriptive-2 "OrgDescriptionList"))
"text:continue-numbering=\"true\"")))
@@ -4092,7 +4111,9 @@ contextual information."
;; Prettify output if needed.
(when org-odt-prettify-xml
(indent-region (point-min) (point-max)))
- (save-buffer 0)))))
+ ;;;(save-buffer 0)
+ (write-file (concat org-odt-zip-dir file))
+ ))))
org-odt-xml-files)
;; Run zip.
(let* ((target --out-file)
- [O] Open Document Exporter, Georg Lehner, 2013/06/24
- Re: [O] Open Document Exporter, Vikas Rawal, 2013/06/24
- Re: [O] Open Document Exporter,
Georg Lehner <=
- Re: [O] Open Document Exporter, Nicolas Goaziou, 2013/06/26
- Re: [O] Open Document Exporter, Georg Lehner, 2013/06/28
- Re: [O] Open Document Exporter, Jambunathan K, 2013/06/29
- Re: [O] Open Document Exporter, Jambunathan K, 2013/06/29