branch: externals/org
commit f7d8c42091e19c9f5ac08f4dcd3bb373efb0d4a3
Author: Derek Chen-Becker <[email protected]>
Commit: Ihor Radchenko <[email protected]>
ox-odt.el: Fix formatting of numeric priorities
* lisp/ox-odt.el (org-odt-format-toc-headline)
(org-odt-format-headline-default-function, org-odt-template): Use
`org-priority-to-string' to format priority values instead of assuming a
character value. Generate appropriate styles only for defined priority
values instead of assuming "A" through "D".
Tested manually via export to an ODT file.
---
etc/styles/OrgOdtStyles.xml | 3 ---
lisp/ox-odt.el | 26 +++++++++++++++++++++-----
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/etc/styles/OrgOdtStyles.xml b/etc/styles/OrgOdtStyles.xml
index 1a8edee99b..982773278d 100644
--- a/etc/styles/OrgOdtStyles.xml
+++ b/etc/styles/OrgOdtStyles.xml
@@ -404,9 +404,6 @@
<style:style style:name="OrgTags" style:family="text"/>
<style:style style:name="OrgPriority" style:family="text"/>
- <style:style style:name="OrgPriority-A" style:family="text"
style:parent-style-name="OrgPriority"/>
- <style:style style:name="OrgPriority-B" style:family="text"
style:parent-style-name="OrgPriority"/>
- <style:style style:name="OrgPriority-C" style:family="text"
style:parent-style-name="OrgPriority"/>
<style:style style:name="OrgTimestamp" style:display-name="OrgTimestamp"
style:family="text">
<style:text-properties style:font-name="Courier New"
fo:background-color="transparent" style:font-name-asian="NSimSun"
style:font-name-complex="Courier New"/>
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index cd4d385f95..a31c12f1c9 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -1122,8 +1122,9 @@ specifying the depth of the table."
(format "<text:span text:style-name=\"%s\">%s</text:span> "
style todo)))
(when priority
- (let* ((style (format "OrgPriority-%s" priority))
- (priority (format "[#%c]" priority)))
+ (let* ((priority-string (org-priority-to-string priority))
+ (style (format "OrgPriority-%s" priority-string))
+ (priority (format "[#%s]" priority-string)))
(format "<text:span text:style-name=\"%s\">%s</text:span> "
style priority)))
;; Title.
@@ -1394,7 +1395,11 @@ original parsed data. INFO is a plist holding export
options."
;; Ensure we have write permissions to this file.
(set-file-modes (concat org-odt-zip-dir "styles.xml") #o600)
- (let ((styles-xml (concat org-odt-zip-dir "styles.xml")))
+ (let ((styles-xml (concat org-odt-zip-dir "styles.xml"))
+ ;; Capture the current (possibly buffer-local) values for priorities
+ ;; because these get reset to global values when we use
`with-temp-buffer'
+ (priority-high org-priority-highest)
+ (priority-low org-priority-lowest))
(with-temp-buffer
(when (file-exists-p styles-xml)
(insert-file-contents styles-xml))
@@ -1426,6 +1431,16 @@ original parsed data. INFO is a plist holding export
options."
(if (wholenump sec-num) (<= level sec-num) sec-num))
(replace-match replacement t nil))))
+ ;; Update styles.xml with priority styles for the current valid
priority range
+ (when (plist-get info :with-priority)
+ (goto-char (point-min))
+ (when (re-search-forward "<style:style style:name=\"OrgPriority\"
style:family=\"text\"/>" nil t)
+ (goto-char (match-end 0))
+ (insert "\n <!-- Org Priority Styles -->\n")
+ (dolist (priority (number-sequence priority-high priority-low))
+ (insert (format " <style:style style:name=\"OrgPriority-%s\"
style:family=\"text\" style:parent-style-name=\"OrgPriority\"/>\n"
+ (org-priority-to-string priority))))))
+
;; Write back the new contents.
(write-region nil nil styles-xml))))
;; Update content.xml.
@@ -1863,8 +1878,9 @@ See `org-odt-format-headline-function' for details."
(let ((style (if (eq todo-type 'done) "OrgDone" "OrgTodo")))
(format "<text:span text:style-name=\"%s\">%s</text:span> " style
todo)))
(when priority
- (let* ((style (format "OrgPriority-%c" priority))
- (priority (format "[#%c]" priority)))
+ (let* ((priority-string (org-priority-to-string priority))
+ (style (format "OrgPriority-%s" priority-string))
+ (priority (format "[#%s]" priority-string)))
(format "<text:span text:style-name=\"%s\">%s</text:span> "
style priority)))
;; Title.