diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-11-10 19:59:12 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-11-10 20:00:02 +0100 |
commit | bea916d9f62ab2e251c9d3be021fb2243364686f (patch) | |
tree | 5c1cf5924f2733096a594b950c496a3c91e4d7d1 | |
parent | af81211fdc01b64449179bcdb77fb1c8ecb3fb94 (diff) | |
download | org-mode-bea916d9f62ab2e251c9d3be021fb2243364686f.tar.gz |
ox-odt: Improve styles file handling
* lisp/ox-odt.el (org-odt-template): Allow double quotes around file
name. Better error handling. Small refactoring.
-rw-r--r-- | lisp/ox-odt.el | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index fd1cb1d..125bec0 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -1357,19 +1357,18 @@ original parsed data. INFO is a plist holding export options." ;; Update styles file. ;; Copy styles.xml. Also dump htmlfontify styles, if there is any. ;; Write styles file. - (let* ((styles-file (plist-get info :odt-styles-file)) - (styles-file (and (org-string-nw-p styles-file) - (org-trim styles-file))) - (styles-file (if (string-match-p "\\`(.*)\\'" styles-file) - (ignore-errors (read styles-file)) - styles-file)) - ;; Non-availability of styles.xml is not a critical - ;; error. For now, throw an error. - (styles-file (or styles-file - (expand-file-name "OrgOdtStyles.xml" - org-odt-styles-dir) - (error "org-odt: Missing styles file?")))) + (let* ((styles-file + (pcase (plist-get info :odt-styles-file) + (`nil (expand-file-name "OrgOdtStyles.xml" org-odt-styles-dir)) + ((and s (pred (string-match-p "\\`(.*)\\'"))) + (condition-case nil + (read s) + (error (user-error "Invalid styles file specification: %S" s)))) + (filename filename)))) (cond + ;; Non-availability of styles.xml is not a critical error. For + ;; now, throw an error. + ((null styles-file) (error "Missing styles file")) ((listp styles-file) (let ((archive (nth 0 styles-file)) (members (nth 1 styles-file))) @@ -1379,7 +1378,7 @@ original parsed data. INFO is a plist holding export options." (let* ((image-type (file-name-extension member)) (media-type (format "image/%s" image-type))) (org-odt-create-manifest-file-entry media-type member)))))) - ((and (stringp styles-file) (file-exists-p styles-file)) + ((file-exists-p styles-file) (let ((styles-file-type (file-name-extension styles-file))) (cond ((string= styles-file-type "xml") |