emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Bug] MCE for HTML test of export
@ 2011-03-15 16:09 Sébastien Vauban
  2011-03-15 17:43 ` Nicolas
  0 siblings, 1 reply; 7+ messages in thread
From: Sébastien Vauban @ 2011-03-15 16:09 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

Here a "minimal complete example" of some functionality that not working fine
in HTML exports. This is for easy testing...

--8<---------------cut here---------------start------------->8---
#+TITLE:     ECM
#+OPTIONS:   H:4 toc:2

* Past appointment
  [2010-04-21 Wed 13:30-14:30]

Notice the =BR= here above...

* TODO Extra BR as well
  DEADLINE: <2012-06-30 Sat>

* Russian dolls

In the following, I see one block in the other, with visible
=ORG-LIST-END-MARKERs=.

*************** TODO To send

- This
- That

*************** END

*************** TODO To receive

- Pictures
- Invoice

*************** END

* Verse for mail extract                                                :mail:
  [2010-07-26 Mon 10:44]

#+begin_verse
Please find here...
#+end_verse

From [[gnus:nnimap%2Bmc:INBOX.folder#0070d1cb2ca3$96c5b2e0$0100a8c0@every][Email from someone]]

The above reference link gets wrongly translated (lt, gt). I know, though,
that such a link does not work from HTML (what a pitty!) -- but I've put it
here for when editing in Emacs...

* DONE Other mail                                                       :mail:

#+begin_verse
Dear,

See how nicely this mail gets translated into HTML.

Since the new implementation of Nicolas:
1. These lists work
2. *really* well!

Unnumbered as well:
- your price
- when you could come.

Best regards.
#+end_verse

** This mail extract is not fully OK

Except this one...

#+begin_verse
I would choose for:

|        |  \EUR |
|--------+-------|
| Test 1 | 17821 |
| Test A |   330 |
|--------+-------|
|        | 18151 |
#+TBLFM: @4$2=vsum(@-I..@-II)

Double backslashes appear above. And this line gets out of the verse env.
#+end_verse

** CANX The URL address gets escaped

Found on [2011-02-07 Mon].

From [[http://www.cathycabine.be/chantier.asp?docid%3D55344&langue%3DFR][Mini-cabines - Cathy Cabine sprl - Amay - Chantier et Evénements - Location cabines sanitaires]]

** URL with underscores

See
http://www.jardideco.fr/boutique/fiche_produit.cfm?ref=76555SZ&type=77&code_lg=lg_fr&num=131

** URL with double dashes

- [[http://www.premiezoeker.be/premie_info?premie=11232][11232 -- Federale belastingvermindering voor de vervanging van oude stookketels (factuur betaald in 2010)]]
--8<---------------cut here---------------end--------------->8---

Best regards,
  Seb

-- 
Sébastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Bug] MCE for HTML test of export
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas @ 2011-03-15 17:43 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode

Hello,

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:

> * Russian dolls
>
> In the following, I see one block in the other, with visible
> =ORG-LIST-END-MARKERs=.
>
> *************** TODO To send
>
> - This
> - That
>
> *************** END
>
> *************** TODO To receive
>
> - Pictures
> - Invoice
>
> *************** END

It will not be very helpful, but: I cannot reproduce it, even with
minimal setup.

Regards,

-- 
Nicolas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Re: [Bug] MCE for HTML test of export
  2011-03-15 17:43 ` Nicolas
@ 2011-03-15 22:08   ` Sébastien Vauban
  2011-03-17 17:05     ` Nicolas
  0 siblings, 1 reply; 7+ messages in thread
From: Sébastien Vauban @ 2011-03-15 22:08 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Nicolas,

Nicolas wrote:
> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>> * Russian dolls
>>
>> In the following, I see one block in the other, with visible
>> =ORG-LIST-END-MARKERs=.
>>
>> *************** TODO To send
>>
>> - This
>> - That
>>
>> *************** END
>>
>> *************** TODO To receive
>>
>> - Pictures
>> - Invoice
>>
>> *************** END
>
> It will not be very helpful, but: I cannot reproduce it, even with
> minimal setup.

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

Best regards,
  Seb

-- 
Sébastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Bug] MCE for HTML test of export
  2011-03-15 22:08   ` Sébastien Vauban
@ 2011-03-17 17:05     ` Nicolas
  2011-03-19 11:05       ` Sébastien Vauban
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas @ 2011-03-17 17:05 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode

[-- 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Bug] MCE for HTML test of export
  2011-03-17 17:05     ` Nicolas
@ 2011-03-19 11:05       ` Sébastien Vauban
  2011-03-19 17:25         ` Nicolas
  0 siblings, 1 reply; 7+ messages in thread
From: Sébastien Vauban @ 2011-03-19 11:05 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Nicolas,

Nicolas wrote:
> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> 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 ?

Perfect. Works like a charm. Please do apply it...

> Also, you may have a look at default templates, as your HTML variant is
> slightly wrong (wrt <br> tag).

I'm not sure to understand what's "wrong". You mean the fact I added manually
a <br> tag after the title?

If yes, it was to have the "title" line (task subject, with TODO keyword) on
its own line, followed by the rest of the entry on subsquent paragraphs.

But, indeed (after testing it), it seems I am not (anymore?) forced to insert
that. Was it this you were talking about?

Thanks for the comment, anyway... and for the patch!

Best regards,
  Seb

-- 
Sébastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Bug] MCE for HTML test of export
  2011-03-19 11:05       ` Sébastien Vauban
@ 2011-03-19 17:25         ` Nicolas
  2011-03-19 17:48           ` Aankhen
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas @ 2011-03-19 17:25 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode

Hello,

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:

> Perfect. Works like a charm. Please do apply it...

Done.

>> Also, you may have a look at default templates, as your HTML variant is
>> slightly wrong (wrt <br> tag).

> I'm not sure to understand what's "wrong". You mean the fact I added manually
> a <br> tag after the title?

I just meant that you could replace <br> by <br />. I think both are
valid HTML-wise, but Emacs doesn't report an error with the latter.

Regards,

-- 
Nicolas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Re: [Bug] MCE for HTML test of export
  2011-03-19 17:25         ` Nicolas
@ 2011-03-19 17:48           ` Aankhen
  0 siblings, 0 replies; 7+ messages in thread
From: Aankhen @ 2011-03-19 17:48 UTC (permalink / raw)
  To: Nicolas, Sébastien Vauban, emacs-orgmode

On Sat, Mar 19, 2011 at 22:55, Nicolas <n.goaziou@gmail.com> wrote:
> [snip]
>
>>> Also, you may have a look at default templates, as your HTML variant is
>>> slightly wrong (wrt <br> tag).
>
>> I'm not sure to understand what's "wrong". You mean the fact I added manually
>> a <br> tag after the title?
>
> I just meant that you could replace <br> by <br />. I think both are
> valid HTML-wise, but Emacs doesn't report an error with the latter.

<br> is valid HTML, <br /> is valid XHTML.  Browsers will treat both
the same way in almost every case since it’s all tag soup to them.[1]
Org uses XHTML as far as I can tell, so <br /> is the correct choice
here.

Aankhen

[1]: Unless you’re serving it up as real XHTML, which I highly doubt. ;-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-03-19 17:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2011-03-19 11:05       ` Sébastien Vauban
2011-03-19 17:25         ` Nicolas
2011-03-19 17:48           ` Aankhen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).