From 68ffdca675a744025aad75a4d866f0bcaa0d0dac Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Sat, 18 Apr 2009 08:34:51 +0200 Subject: [PATCH] Docbook export: Improve timestamp handling --- lisp/ChangeLog | 6 ++++++ lisp/org-docbook.el | 52 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c6f4774b7..dbf3b8f64 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2009-04-18 Carsten Dominik + + * org-docbook.el (org-export-docbook-keywords-markup) + (org-export-docbook-timestamp-markup): New options. + (org-export-docbook-protect-tags): New function. + 2009-04-17 Carsten Dominik * org-id.el (org-id-get-with-outline-path-completion): Turn off diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index 13b46ed6b..12dbe6a78 100644 --- a/lisp/org-docbook.el +++ b/lisp/org-docbook.el @@ -233,6 +233,16 @@ the variable to :group 'org-export-docbook :type 'string) +(defcustom org-export-docbook-keywords-markup "%s" + "A printf format string to be applied to keywords by DocBook exporter." + :group 'org-export-docbook + :type 'string) + +(defcustom org-export-docbook-timestamp-markup "%s" + "A printf format string to be applied to time stamps by DocBook exporter." + :group 'org-export-docbook + :type 'string) + ;;; Autoload functions: ;;;###autoload @@ -728,9 +738,13 @@ publishing directory." (org-solidify-link-text (match-string 1 line))) t t line))))) - ;; Replace "&" by "&", "<" and ">" by "<" and ">" - ;; handle @<..> HTML tags (replace "@>..<" by "<..>") - ;; Also handle sub_superscripts and checkboxes + ;; Put time stamps and related keywords into special mark-up + ;; elements. + (setq line (org-export-docbook-handle-time-stamps line)) + + ;; Replace "&", "<" and ">" by "&", "<" and ">". + ;; Handle @<..> HTML tags (replace "@>..<" by "<..>"). + ;; Also handle sub_superscripts and check boxes. (or (string-match org-table-hline-regexp line) (setq line (org-docbook-expand line))) @@ -1321,6 +1335,38 @@ TABLE is a string containing the HTML code generated by (setq string (replace-match (match-string 1 string) t t string))) string)) +(defun org-export-docbook-protect-tags (string) + "Change ``<...>'' in string STRING into ``@<...>''. +This is normally needed when STRING contains DocBook elements +that need to be preserved in later phase of DocBook exporting." + (let ((start 0)) + (while (string-match "<\\([^>]*\\)>" string start) + (setq string (replace-match + "@<\\1>" t nil string) + start (match-end 0))) + string)) + +(defun org-export-docbook-handle-time-stamps (line) + "Format time stamps in string LINE." + (let (replaced + (kw-markup (org-export-docbook-protect-tags + org-export-docbook-keywords-markup)) + (ts-markup (org-export-docbook-protect-tags + org-export-docbook-timestamp-markup))) + (while (string-match org-maybe-keyword-time-regexp line) + (setq replaced + (concat replaced + (substring line 0 (match-beginning 0)) + (if (match-end 1) + (format kw-markup + (match-string 1 line))) + " " + (format ts-markup + (substring (org-translate-time + (match-string 3 line)) 1 -1))) + line (substring line (match-end 0)))) + (concat replaced line))) + (provide 'org-docbook) ;;; org-docbook.el ends here