Docbook export: Improve timestamp handling

This commit is contained in:
Carsten Dominik 2009-04-18 08:34:51 +02:00
parent 4b4328e29b
commit 68ffdca675
2 changed files with 55 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2009-04-18 Carsten Dominik <carsten.dominik@gmail.com>
* 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 <carsten.dominik@gmail.com>
* org-id.el (org-id-get-with-outline-path-completion): Turn off

View File

@ -233,6 +233,16 @@ the variable to
:group 'org-export-docbook
:type 'string)
(defcustom org-export-docbook-keywords-markup "<literal>%s</literal>"
"A printf format string to be applied to keywords by DocBook exporter."
:group 'org-export-docbook
:type 'string)
(defcustom org-export-docbook-timestamp-markup "<emphasis>%s</emphasis>"
"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 "&amp;", "<" and ">" by "&lt;" and "&gt;"
;; handle @<..> HTML tags (replace "@&gt;..&lt;" 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 "&amp;", "&lt;" and "&gt;".
;; Handle @<..> HTML tags (replace "@&gt;..&lt;" 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