Parcourir la source

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.
Nicolas Goaziou il y a 14 ans
Parent
commit
d7a799cc86
2 fichiers modifiés avec 18 ajouts et 14 suppressions
  1. 17 12
      lisp/org-inlinetask.el
  2. 1 2
      lisp/org-list.el

+ 17 - 12
lisp/org-inlinetask.el

@@ -105,12 +105,12 @@ When nil, they will not be exported."
   :type 'boolean)
 
 (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 "")
 	      (format "<span class=\"%s %s\">%s%s</span> "
 		      class todo todo priority))
 	    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))
 	     heading content))
     (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
 		     (1- (* 2 (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))
 	 headline beg end stars content)
     (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)
 	    (delete-region beg (1+ (match-end 0)))))
       (setq beg (point))
-      (when (and (re-search-forward "^\\(\\*+\\) " nil t)
+      (when (and (re-search-forward "^\\(\\*+\\)[ \t]+" nil t)
 		 (= (length (match-string 1)) (length stars))
 		 (progn (goto-char (match-end 0))
 			(looking-at "END[ \t]*$")))
@@ -281,7 +281,10 @@ Either remove headline and meta data, or do special formatting."
 	      (if (string-match "[ \t\n]+\\'" content)
 		  (setq content (substring content 0 (match-beginning 0))))
 	      (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
 	(when (string-match org-complex-heading-regexp 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) ""))
 		 (tags (or (match-string 5 headline) ""))
 		 (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)))
-		 ;; change nil arguments into empty strings
-		 (nil-to-str (lambda (el) (or (eval el) "")))
-		 ;; build and protect export string
+		 (nil-to-str
+		  ;; Change nil arguments into empty strings
+		  (lambda (el) (or (eval el) "")))
+		 ;; Build and ensure export string will not break lists
 		 (export-str (org-add-props
 				 (eval (append '(format format-str)
 					       (mapcar nil-to-str tokens)))
-				 nil 'org-protected t)))
-	    ;; eventually insert it
+				 '(original-indentation 1000))))
+	    ;; Eventually insert it
 	    (insert export-str "\n")))))))
 
 (defun org-inlinetask-get-current-indentation ()
@@ -337,7 +342,7 @@ Either remove headline and meta data, or do special formatting."
     (replace-match "")))
 
 (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))
 (eval-after-load "org"
   '(add-hook 'org-font-lock-hook 'org-inlinetask-fontify))

+ 1 - 2
lisp/org-list.el

@@ -1189,8 +1189,7 @@ Assume point is at an item."
 	      (re-search-forward "^[ \t]*:END:" nil t)
 	      (forward-line 1))
 	     ((and inlinetask-re (looking-at inlinetask-re))
-	      (org-inlinetask-goto-end)
-	      (forward-line 1))
+	      (org-inlinetask-goto-end))
 	     ((looking-at "^[ \t]*$")
 	      (forward-line 1))
 	     ((org-at-item-p)