org-inlinetask: fix export of inline tasks within lists
* lisp/org-inlinetask.el (org-inlinetask-export-templates): slightly modify templates so environment boundaries don't interfere with content of task. Unprotect content of task so it might benefit from further transformations. Set original-indentation property to a high value to ensure that task is always in the last item of the list. Also, apply templates later in export process. * lisp/org-list.el (org-list-struct): fix inline task skipping.
This commit is contained in:
parent
79553c4764
commit
d7a799cc86
|
@ -105,12 +105,12 @@ When nil, they will not be exported."
|
||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
(defvar org-inlinetask-export-templates
|
(defvar org-inlinetask-export-templates
|
||||||
'((html "<pre class=\"inlinetask\"><b>%s%s</b><br>%s</pre>"
|
'((html "<pre class=\"inlinetask\"><b>%s%s</b><br />\n%s\n</pre>"
|
||||||
'((unless (eq todo "")
|
'((unless (eq todo "")
|
||||||
(format "<span class=\"%s %s\">%s%s</span> "
|
(format "<span class=\"%s %s\">%s%s</span> "
|
||||||
class todo todo priority))
|
class todo todo priority))
|
||||||
heading content))
|
heading content))
|
||||||
(latex "\\begin\{description\}\\item[%s%s]%s\\end\{description\}"
|
(latex "\\begin\{description\}\n\\item[%s%s]~\n%s\n\\end\{description\}"
|
||||||
'((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority))
|
'((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority))
|
||||||
heading content))
|
heading content))
|
||||||
(ascii " -- %s%s%s"
|
(ascii " -- %s%s%s"
|
||||||
|
@ -251,7 +251,7 @@ Either remove headline and meta data, or do special formatting."
|
||||||
(let* ((nstars (if org-odd-levels-only
|
(let* ((nstars (if org-odd-levels-only
|
||||||
(1- (* 2 (or org-inlinetask-min-level 200)))
|
(1- (* 2 (or org-inlinetask-min-level 200)))
|
||||||
(or org-inlinetask-min-level 200)))
|
(or org-inlinetask-min-level 200)))
|
||||||
(re1 (format "^\\(\\*\\{%d,\\}\\) .*\n" nstars))
|
(re1 (format "^\\(\\*\\{%d,\\}\\)[ \t]+.*\n" nstars))
|
||||||
(re2 (concat "^[ \t]*" org-keyword-time-regexp))
|
(re2 (concat "^[ \t]*" org-keyword-time-regexp))
|
||||||
headline beg end stars content)
|
headline beg end stars content)
|
||||||
(while (re-search-forward re1 nil t)
|
(while (re-search-forward re1 nil t)
|
||||||
|
@ -266,7 +266,7 @@ Either remove headline and meta data, or do special formatting."
|
||||||
(if (re-search-forward org-property-end-re nil t)
|
(if (re-search-forward org-property-end-re nil t)
|
||||||
(delete-region beg (1+ (match-end 0)))))
|
(delete-region beg (1+ (match-end 0)))))
|
||||||
(setq beg (point))
|
(setq beg (point))
|
||||||
(when (and (re-search-forward "^\\(\\*+\\) " nil t)
|
(when (and (re-search-forward "^\\(\\*+\\)[ \t]+" nil t)
|
||||||
(= (length (match-string 1)) (length stars))
|
(= (length (match-string 1)) (length stars))
|
||||||
(progn (goto-char (match-end 0))
|
(progn (goto-char (match-end 0))
|
||||||
(looking-at "END[ \t]*$")))
|
(looking-at "END[ \t]*$")))
|
||||||
|
@ -281,7 +281,10 @@ Either remove headline and meta data, or do special formatting."
|
||||||
(if (string-match "[ \t\n]+\\'" content)
|
(if (string-match "[ \t\n]+\\'" content)
|
||||||
(setq content (substring content 0 (match-beginning 0))))
|
(setq content (substring content 0 (match-beginning 0))))
|
||||||
(setq content (org-remove-indentation content))))
|
(setq content (org-remove-indentation content))))
|
||||||
(setq content (or content ""))
|
;; Prevent from protecting content if there's any
|
||||||
|
(setq content (or (and content
|
||||||
|
(org-add-props content '(org-protected nil)))
|
||||||
|
""))
|
||||||
;; grab elements to export
|
;; grab elements to export
|
||||||
(when (string-match org-complex-heading-regexp headline)
|
(when (string-match org-complex-heading-regexp headline)
|
||||||
(let* ((todo (or (match-string 2 headline) ""))
|
(let* ((todo (or (match-string 2 headline) ""))
|
||||||
|
@ -291,16 +294,18 @@ Either remove headline and meta data, or do special formatting."
|
||||||
(heading (or (match-string 4 headline) ""))
|
(heading (or (match-string 4 headline) ""))
|
||||||
(tags (or (match-string 5 headline) ""))
|
(tags (or (match-string 5 headline) ""))
|
||||||
(backend-spec (assq backend org-inlinetask-export-templates))
|
(backend-spec (assq backend org-inlinetask-export-templates))
|
||||||
(format-str (nth 1 backend-spec))
|
(format-str (org-add-props (nth 1 backend-spec)
|
||||||
|
'(org-protected t)))
|
||||||
(tokens (cadr (nth 2 backend-spec)))
|
(tokens (cadr (nth 2 backend-spec)))
|
||||||
;; change nil arguments into empty strings
|
(nil-to-str
|
||||||
(nil-to-str (lambda (el) (or (eval el) "")))
|
;; Change nil arguments into empty strings
|
||||||
;; build and protect export string
|
(lambda (el) (or (eval el) "")))
|
||||||
|
;; Build and ensure export string will not break lists
|
||||||
(export-str (org-add-props
|
(export-str (org-add-props
|
||||||
(eval (append '(format format-str)
|
(eval (append '(format format-str)
|
||||||
(mapcar nil-to-str tokens)))
|
(mapcar nil-to-str tokens)))
|
||||||
nil 'org-protected t)))
|
'(original-indentation 1000))))
|
||||||
;; eventually insert it
|
;; Eventually insert it
|
||||||
(insert export-str "\n")))))))
|
(insert export-str "\n")))))))
|
||||||
|
|
||||||
(defun org-inlinetask-get-current-indentation ()
|
(defun org-inlinetask-get-current-indentation ()
|
||||||
|
@ -337,7 +342,7 @@ Either remove headline and meta data, or do special formatting."
|
||||||
(replace-match "")))
|
(replace-match "")))
|
||||||
|
|
||||||
(eval-after-load "org-exp"
|
(eval-after-load "org-exp"
|
||||||
'(add-hook 'org-export-preprocess-after-tree-selection-hook
|
'(add-hook 'org-export-preprocess-before-backend-specifics-hook
|
||||||
'org-inlinetask-export-handler))
|
'org-inlinetask-export-handler))
|
||||||
(eval-after-load "org"
|
(eval-after-load "org"
|
||||||
'(add-hook 'org-font-lock-hook 'org-inlinetask-fontify))
|
'(add-hook 'org-font-lock-hook 'org-inlinetask-fontify))
|
||||||
|
|
|
@ -1189,8 +1189,7 @@ Assume point is at an item."
|
||||||
(re-search-forward "^[ \t]*:END:" nil t)
|
(re-search-forward "^[ \t]*:END:" nil t)
|
||||||
(forward-line 1))
|
(forward-line 1))
|
||||||
((and inlinetask-re (looking-at inlinetask-re))
|
((and inlinetask-re (looking-at inlinetask-re))
|
||||||
(org-inlinetask-goto-end)
|
(org-inlinetask-goto-end))
|
||||||
(forward-line 1))
|
|
||||||
((looking-at "^[ \t]*$")
|
((looking-at "^[ \t]*$")
|
||||||
(forward-line 1))
|
(forward-line 1))
|
||||||
((org-at-item-p)
|
((org-at-item-p)
|
||||||
|
|
Loading…
Reference in New Issue