From: Nicolas <n.goaziou@gmail.com>
To: "Sébastien Vauban" <wxhgmqzgwmuf@spammotel.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [Bug] MCE for HTML test of export
Date: Thu, 17 Mar 2011 18:05:02 +0100 [thread overview]
Message-ID: <87d3lp8ypt.fsf@gmail.com> (raw)
In-Reply-To: <80lj0gqboz.fsf@somewhere.org> ("Sébastien Vauban"'s message of "Tue, 15 Mar 2011 23:08:12 +0100")
[-- Attachment #1: Type: text/plain, Size: 1799 bytes --]
Hello,
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
> Regarding this problem only, it must be an interaction then with my following
> setting for the inline task in HTML:
>
> #+begin_src emacs-lisp
> ;; templates for inline tasks in various exporters
> (setq org-inlinetask-export-templates
> '((html "<pre class=\"inlinetask\"><b>%s%s</b><br>%s</pre>"
> '((unless (eq todo "")
> (format "<span class=\"%s %s\">%s%s</span> "
> class todo todo priority))
> heading content))
> (latex "\\todo[inline]{\\textbf{\\textsf{%s %s}}\\linebreak{} %s}"
> '((unless (eq todo "")
> (format "\\textsc{%s%s}" todo priority))
> heading content))
> (ascii " -- %s%s%s"
> '((unless (eq todo "")
> (format "%s%s " todo priority))
> heading
> (unless (eq content "")
> (format "\n ¦ %s"
> (mapconcat 'identity
> (org-split-string content "\n")
> "\n ¦ ")))))))
> #+end_src
Indeed, it came from your templates. To prevent this, I made sure, with
the following patch, that CONTENT is always enclosed by newline
characters. Would you mind testing it before I apply it ?
Also, you may have a look at default templates, as your HTML variant is
slightly wrong (wrt <br> tag).
Thanks.
Regards,
--
Nicolas
[-- Attachment #2: fix for inline task export --]
[-- Type: text/plain, Size: 6251 bytes --]
From 35c116e16b319354322318b8405e557a61da4459 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Thu, 17 Mar 2011 12:12:31 +0100
Subject: [PATCH] org-inlinetask: modify export of inline tasks
* lisp/org-inlinetask.el (org-inlinetask-export-templates): fix
default templates.
(org-inlinetask-export-handler): Ensure contents of inline task, if
any, starts and ends with a newline character. Refactor and comment
code.
---
lisp/org-inlinetask.el | 98 ++++++++++++++++++++++++++----------------------
1 files changed, 53 insertions(+), 45 deletions(-)
diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el
index 990a1ac..96809ce 100644
--- a/lisp/org-inlinetask.el
+++ b/lisp/org-inlinetask.el
@@ -107,12 +107,12 @@ When nil, they will not be exported."
:type 'boolean)
(defvar org-inlinetask-export-templates
- '((html "<pre class=\"inlinetask\"><b>%s%s</b><br />\n%s\n</pre>"
+ '((html "<pre class=\"inlinetask\"><b>%s%s</b><br />%s</pre>"
'((unless (eq todo "")
(format "<span class=\"%s %s\">%s%s</span> "
class todo todo priority))
heading content))
- (latex "\\begin\{description\}\n\\item[%s%s]~\n%s\n\\end\{description\}"
+ (latex "\\begin\{description\}\n\\item[%s%s]~%s\\end\{description\}"
'((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority))
heading content))
(ascii " -- %s%s%s"
@@ -306,66 +306,74 @@ If the task has an end part, also demote it."
"Handle headlines with level larger or equal to `org-inlinetask-min-level'.
Either remove headline and meta data, or do special formatting."
(goto-char (point-min))
- (let* ((nstars (if org-odd-levels-only
- (1- (* 2 (or org-inlinetask-min-level 200)))
- (or org-inlinetask-min-level 200)))
- (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)
- (setq headline (match-string 0)
- stars (match-string 1)
- content nil)
- (replace-match "")
- (while (looking-at re2)
- (delete-region (point) (1+ (point-at-eol))))
- (while (looking-at org-drawer-regexp)
- (setq beg (point))
- (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 "^\\(\\*+\\)[ \t]+" nil t)
- (= (length (match-string 1)) (length stars))
- (progn (goto-char (match-end 0))
- (looking-at "END[ \t]*$")))
- (setq content (buffer-substring beg (1- (point-at-bol))))
- (delete-region beg (1+ (match-end 0))))
+ (let* ((keywords-re (concat "^[ \t]*" org-keyword-time-regexp))
+ (inline-re (concat (org-inlinetask-outline-regexp) ".*")))
+ (while (re-search-forward inline-re nil t)
+ (let ((headline (match-string 0))
+ (beg (point-at-bol))
+ (end (copy-marker (save-excursion
+ (org-inlinetask-goto-end) (point))))
+ content)
+ ;; Delete SCHEDULED, DEADLINE...
+ (while (re-search-forward keywords-re end t)
+ (delete-region (point-at-bol) (1+ (point-at-eol))))
+ (goto-char beg)
+ ;; Delete drawers
+ (while (re-search-forward org-drawer-regexp end t)
+ (when (save-excursion (re-search-forward org-property-end-re nil t))
+ (delete-region beg (1+ (match-end 0)))))
+ ;; Get CONTENT, if any.
+ (goto-char beg)
+ (forward-line 1)
+ (unless (= (point) end)
+ (setq content (buffer-substring (point)
+ (save-excursion (goto-char end)
+ (forward-line -1)
+ (point)))))
+ ;; Remove the task.
(goto-char beg)
+ (delete-region beg end)
(when org-inlinetask-export
- ;; content formatting
- (when content
- (if (not (string-match "\\S-" content))
- (setq content nil)
- (if (string-match "[ \t\n]+\\'" content)
+ ;; Format CONTENT, if appropriate.
+ (setq content
+ (if (not (and content (string-match "\\S-" content)))
+ ""
+ ;; Ensure CONTENT has minimal indentation, a single
+ ;; newline character at its boundaries, and isn't
+ ;; protected.
+ (when (string-match "`\\([ \t]*\n\\)+" content)
+ (setq content (substring content (match-end 0))))
+ (when (string-match "[ \t\n]+\\'" content)
(setq content (substring content 0 (match-beginning 0))))
- (setq content (org-remove-indentation 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
+ (org-add-props (concat "\n" (org-remove-indentation content) "\n")
+ '(org-protected nil))))
(when (string-match org-complex-heading-regexp headline)
- (let* ((todo (or (match-string 2 headline) ""))
+ (let* ((nil-to-str
+ (function
+ ;; Change nil arguments into empty strings.
+ (lambda (el) (or (eval el) ""))))
+ ;; Set up keywords provided to templates.
+ (todo (or (match-string 2 headline) ""))
(class (or (and (eq "" todo) "")
(if (member todo org-done-keywords) "done" "todo")))
(priority (or (match-string 3 headline) ""))
(heading (or (match-string 4 headline) ""))
(tags (or (match-string 5 headline) ""))
- (backend-spec (assq org-export-current-backend
+ ;; Read `org-inlinetask-export-templates'.
+ (backend-spec (assq org-export-current-backend
org-inlinetask-export-templates))
(format-str (org-add-props (nth 1 backend-spec)
'(org-protected t)))
(tokens (cadr (nth 2 backend-spec)))
- (nil-to-str
- ;; Change nil arguments into empty strings
- (lambda (el) (or (eval el) "")))
- ;; Build and ensure export string will not break lists
+ ;; Build export string. Ensure it won't break
+ ;; surrounding lists by giving it arbitrary high
+ ;; indentation.
(export-str (org-add-props
(eval (append '(format format-str)
(mapcar nil-to-str tokens)))
'(original-indentation 1000))))
- ;; Eventually insert it
- (insert export-str "\n")))))))
+ (insert export-str)
+ (unless (bolp) (insert "\n")))))))))
(defun org-inlinetask-get-current-indentation ()
"Get the indentation of the last non-while line above this one."
--
1.7.4.1
next prev parent reply other threads:[~2011-03-17 17:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-15 16:09 [Bug] MCE for HTML test of export Sébastien Vauban
2011-03-15 17:43 ` Nicolas
2011-03-15 22:08 ` Sébastien Vauban
2011-03-17 17:05 ` Nicolas [this message]
2011-03-19 11:05 ` Sébastien Vauban
2011-03-19 17:25 ` Nicolas
2011-03-19 17:48 ` Aankhen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d3lp8ypt.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=wxhgmqzgwmuf@spammotel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.