emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] OrgTbl exports raw ampersands in HTML
@ 2010-10-13 16:06 Ivan Vilata i Balaguer
  2010-10-13 16:37 ` Nick Dokos
  0 siblings, 1 reply; 9+ messages in thread
From: Ivan Vilata i Balaguer @ 2010-10-13 16:06 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 460 bytes --]

(This is a rewrite of my previous post so it gets properly noticed as a
bug. ;) )

When generating HTML tables with ampersands in the text, OrgTbl outputs
raw ampersands (&) instead of escaped ampersands (&), which renders
the file invalid.  This bug does not affect normal HTML generation when
exporting standalone files.  I'm using Org version 7.01h.  I've attached
a sample HTML file with an OrgTbl table in it so you can check for
yourselves.  Thanks!

[-- Attachment #2: ~/tmp/prova.html --]
[-- Type: message/external-body, Size: 119 bytes --]

[-- Attachment #3: Type: text/plain, Size: 62 bytes --]


-- 
Ivan Vilata i Balaguer -- http://ivan.lovesgazpacho.net/

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [BUG] OrgTbl exports raw ampersands in HTML
  2010-10-13 16:06 [BUG] OrgTbl exports raw ampersands in HTML Ivan Vilata i Balaguer
@ 2010-10-13 16:37 ` Nick Dokos
  2010-10-13 17:59   ` Ivan Vilata i Balaguer
  0 siblings, 1 reply; 9+ messages in thread
From: Nick Dokos @ 2010-10-13 16:37 UTC (permalink / raw)
  To: Ivan Vilata i Balaguer; +Cc: nicholas.dokos, emacs-orgmode

Ivan Vilata i Balaguer <ivan@selidor.net> wrote:

> (This is a rewrite of my previous post so it gets properly noticed as a
> bug. ;) )
> 
> When generating HTML tables with ampersands in the text, OrgTbl outputs
> raw ampersands (&) instead of escaped ampersands (&amp;), which renders
> the file invalid.  This bug does not affect normal HTML generation when
> exporting standalone files.  I'm using Org version 7.01h.  I've attached
> a sample HTML file with an OrgTbl table in it so you can check for
> yourselves.  Thanks!
> 

I confess I looked at your original report, was baffled by it, started
composing a reply but was distracted before sending it.

AFAIK, orgtbl-mode is a minor mode so that you can use org's table
generation facilities in other modes (e.g. text, or including a table
in a comment in a C/python/perl/foo source file, or in mail...)
In particular, it does not generate HTML. That is done by org's export
facilities. So either your description is inaccurate or my understanding
is flawed. Given the absence of responses, I suspect other people share
my bafflement.

It would help if you described the process you used exactly:

o I started with a file in foo major mode with these contents...

o I enabled orgtbl-mode and added a table like this...

o Then I did this-that-and-the-other to generate an HTML file which
  looks like this...

Thanks,
Nick

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

* Re: [BUG] OrgTbl exports raw ampersands in HTML
  2010-10-13 16:37 ` Nick Dokos
@ 2010-10-13 17:59   ` Ivan Vilata i Balaguer
  2010-10-13 19:10     ` Nick Dokos
  0 siblings, 1 reply; 9+ messages in thread
From: Ivan Vilata i Balaguer @ 2010-10-13 17:59 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

Nick Dokos (2010-10-13 18:37:11 +0200) wrote:

> AFAIK, orgtbl-mode is a minor mode so that you can use org's table
> generation facilities in other modes (e.g. text, or including a table
> in a comment in a C/python/perl/foo source file, or in mail...)
> In particular, it does not generate HTML. That is done by org's export
> facilities. So either your description is inaccurate or my understanding
> is flawed. Given the absence of responses, I suspect other people share
> my bafflement.
>
> It would help if you described the process you used exactly:

Of course, Nick.  First, I write an HTML file like the attached one,
which already has an OrgTbl table and the markers describing where it is
going to be output.  Then I enable orgtbl-mode, I place the cursor over
the table and press C-c C-c.  The table is output in HTML between the
markers.

The problem is that "foo&bar" in the original table gets exported as
"foo&bar", when it should be exported as "foo&amp;bar" to avoid spoling
the HTML code.

I hope it's clear enough this time. :)

[-- Attachment #2: ~/tmp/prova.html --]
[-- Type: message/external-body, Size: 119 bytes --]

[-- Attachment #3: Type: text/plain, Size: 62 bytes --]


-- 
Ivan Vilata i Balaguer -- http://ivan.lovesgazpacho.net/

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Re: [BUG] OrgTbl exports raw ampersands in HTML
  2010-10-13 17:59   ` Ivan Vilata i Balaguer
@ 2010-10-13 19:10     ` Nick Dokos
  2010-10-13 20:23       ` Ivan Vilata i Balaguer
  0 siblings, 1 reply; 9+ messages in thread
From: Nick Dokos @ 2010-10-13 19:10 UTC (permalink / raw)
  To: Ivan Vilata i Balaguer; +Cc: nicholas.dokos, emacs-orgmode

Ivan Vilata i Balaguer <ivan@selidor.net> wrote:

> --=-=-=
> 
> Nick Dokos (2010-10-13 18:37:11 +0200) wrote:
> 
> > AFAIK, orgtbl-mode is a minor mode so that you can use org's table
> > generation facilities in other modes (e.g. text, or including a table
> > in a comment in a C/python/perl/foo source file, or in mail...)
> > In particular, it does not generate HTML. That is done by org's export
> > facilities. So either your description is inaccurate or my understanding
> > is flawed. Given the absence of responses, I suspect other people share
> > my bafflement.
> >
> > It would help if you described the process you used exactly:
> 
> Of course, Nick.  First, I write an HTML file like the attached one,
> which already has an OrgTbl table and the markers describing where it is
> going to be output.  Then I enable orgtbl-mode, I place the cursor over
> the table and press C-c C-c.  The table is output in HTML between the
> markers.
> 
> The problem is that "foo&bar" in the original table gets exported as
> "foo&bar", when it should be exported as "foo&amp;bar" to avoid spoling
> the HTML code.
> 
> I hope it's clear enough this time. :)
> 

Yes, thanks. I'll try it out later. FWIW, my mail reader does not see an
attachment in your message: all I get is the following attachmen with an external
body. Not sure whose fault that is though: maybe mh-e gets hopelessly confused
with it. Can you post the HTML file inline?

Thanks,
Nick


> --=-=-=
> Content-Type: message/external-body; name*=us-ascii''~%2ftmp%2fprova.html;
>  access-type=local-file
> 
> Content-Type: text/html
> Content-ID: <87y6a2nfcg.fsf@rampella.terramar.selidor.net>
> Content-Transfer-Encoding: binary
> 
> 
> 
> --=-=-=
> 
> 
> -- 
> Ivan Vilata i Balaguer -- http://ivan.lovesgazpacho.net/
> 
> --=-=-=
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 
> --=-=-=--
> 
> 

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

* Re: [BUG] OrgTbl exports raw ampersands in HTML
  2010-10-13 19:10     ` Nick Dokos
@ 2010-10-13 20:23       ` Ivan Vilata i Balaguer
  2010-10-13 20:52         ` Nick Dokos
  0 siblings, 1 reply; 9+ messages in thread
From: Ivan Vilata i Balaguer @ 2010-10-13 20:23 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos (2010-10-13 21:10:33 +0200) wrote:

> Yes, thanks. I'll try it out later. FWIW, my mail reader does not see
> an attachment in your message: all I get is the following attachmen
> with an external body. Not sure whose fault that is though: maybe mh-e
> gets hopelessly confused with it. Can you post the HTML file inline?

Argh, I made an external attachment, sorry.  Here you have the file:

----8<----
<html>
  <body>
<!-- [CDATA[
#+ORGTBL: SEND test orgtbl-to-html
| foo&bar |
]] -->
<!-- BEGIN RECEIVE ORGTBL test -->
<!-- END RECEIVE ORGTBL test -->
  </body>
</html>
----8<----

-- 
Ivan Vilata i Balaguer -- http://ivan.lovesgazpacho.net/

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

* Re: Re: [BUG] OrgTbl exports raw ampersands in HTML
  2010-10-13 20:23       ` Ivan Vilata i Balaguer
@ 2010-10-13 20:52         ` Nick Dokos
  2010-10-15  6:24           ` Carsten Dominik
  2010-10-15 12:31           ` Ivan Vilata i Balaguer
  0 siblings, 2 replies; 9+ messages in thread
From: Nick Dokos @ 2010-10-13 20:52 UTC (permalink / raw)
  To: Ivan Vilata i Balaguer; +Cc: nicholas.dokos, emacs-orgmode

Ivan Vilata i Balaguer <ivan@selidor.net> wrote:

> Nick Dokos (2010-10-13 21:10:33 +0200) wrote:
> 
> > Yes, thanks. I'll try it out later. FWIW, my mail reader does not see
> > an attachment in your message: all I get is the following attachmen
> > with an external body. Not sure whose fault that is though: maybe mh-e
> > gets hopelessly confused with it. Can you post the HTML file inline?
> 
> Argh, I made an external attachment, sorry.  Here you have the file:
> 
> ----8<----
> <html>
>   <body>
> <!-- [CDATA[
> #+ORGTBL: SEND test orgtbl-to-html
> | foo&bar |
> ]] -->
> <!-- BEGIN RECEIVE ORGTBL test -->
> <!-- END RECEIVE ORGTBL test -->
>   </body>
> </html>
> ----8<----
> 

The following patch should fix it:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org-html.el b/lisp/org-html.el
index 3fd7b72..f7824ce 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1885,7 +1885,7 @@ lang=\"%s\" xml:lang=\"%s\">
 	      ;; ignore this line
 	      (throw 'next-line t)))
 	;; Break the line into fields
-	(setq fields (org-split-string line "[ \t]*|[ \t]*"))
+	(setq fields (mapcar (function org-html-expand) (org-split-string line "[ \t]*|[ \t]*")))
 	(unless fnum (setq fnum (make-vector (length fields) 0)
 			   nfields (length fnum)))
 	(setq nline (1+ nline) i -1
--8<---------------cut here---------------end--------------->8---


HTH,
Nick

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

* Re: Re: [BUG] OrgTbl exports raw ampersands in HTML
  2010-10-13 20:52         ` Nick Dokos
@ 2010-10-15  6:24           ` Carsten Dominik
  2010-10-15 12:22             ` Nick Dokos
  2010-10-15 12:31           ` Ivan Vilata i Balaguer
  1 sibling, 1 reply; 9+ messages in thread
From: Carsten Dominik @ 2010-10-15  6:24 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode, Ivan Vilata i Balaguer


On Oct 13, 2010, at 10:52 PM, Nick Dokos wrote:

> Ivan Vilata i Balaguer <ivan@selidor.net> wrote:
>
>> Nick Dokos (2010-10-13 21:10:33 +0200) wrote:
>>
>>> Yes, thanks. I'll try it out later. FWIW, my mail reader does not  
>>> see
>>> an attachment in your message: all I get is the following attachmen
>>> with an external body. Not sure whose fault that is though: maybe  
>>> mh-e
>>> gets hopelessly confused with it. Can you post the HTML file inline?
>>
>> Argh, I made an external attachment, sorry.  Here you have the file:
>>
>> ----8<----
>> <html>
>>  <body>
>> <!-- [CDATA[
>> #+ORGTBL: SEND test orgtbl-to-html
>> | foo&bar |
>> ]] -->
>> <!-- BEGIN RECEIVE ORGTBL test -->
>> <!-- END RECEIVE ORGTBL test -->
>>  </body>
>> </html>
>> ----8<----
>>
>
> The following patch should fix it:
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index 3fd7b72..f7824ce 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -1885,7 +1885,7 @@ lang=\"%s\" xml:lang=\"%s\">
> 	      ;; ignore this line
> 	      (throw 'next-line t)))
> 	;; Break the line into fields
> -	(setq fields (org-split-string line "[ \t]*|[ \t]*"))
> +	(setq fields (mapcar (function org-html-expand) (org-split-string  
> line "[ \t]*|[ \t]*")))
> 	(unless fnum (setq fnum (make-vector (length fields) 0)
> 			   nfields (length fnum)))
> 	(setq nline (1+ nline) i -1
> --8<---------------cut here---------------end--------------->8---

Hi Nick, this is the right medicine, in the wrong place.
It needs to be done in orgtbl-to-html.  The function
where you inserted the call to org-html-expand is also
used by the general html exporter, and during normal
html export, org-html-expand is already called at an
earlier stage.

Anyway, thanks a lot for doing 90% of the work!

- Carsten

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

* Re: Re: [BUG] OrgTbl exports raw ampersands in HTML
  2010-10-15  6:24           ` Carsten Dominik
@ 2010-10-15 12:22             ` Nick Dokos
  0 siblings, 0 replies; 9+ messages in thread
From: Nick Dokos @ 2010-10-15 12:22 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: nicholas.dokos, emacs-orgmode, Ivan Vilata i Balaguer

Carsten Dominik <carsten.dominik@gmail.com> wrote:


> Hi Nick, this is the right medicine, in the wrong place.
> It needs to be done in orgtbl-to-html.  The function
> where you inserted the call to org-html-expand is also
> used by the general html exporter, and during normal
> html export, org-html-expand is already called at an
> earlier stage.
> 

Ah, OK - sorry about that.

Thanks,
Nick

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

* Re: [BUG] OrgTbl exports raw ampersands in HTML
  2010-10-13 20:52         ` Nick Dokos
  2010-10-15  6:24           ` Carsten Dominik
@ 2010-10-15 12:31           ` Ivan Vilata i Balaguer
  1 sibling, 0 replies; 9+ messages in thread
From: Ivan Vilata i Balaguer @ 2010-10-15 12:31 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos (2010-10-13 22:52:02 +0200) wrote:

> The following patch should fix it:

Thanks for the patch, Nick!

-- 
Ivan Vilata i Balaguer -- http://ivan.lovesgazpacho.net/

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

end of thread, other threads:[~2010-10-15 12:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-13 16:06 [BUG] OrgTbl exports raw ampersands in HTML Ivan Vilata i Balaguer
2010-10-13 16:37 ` Nick Dokos
2010-10-13 17:59   ` Ivan Vilata i Balaguer
2010-10-13 19:10     ` Nick Dokos
2010-10-13 20:23       ` Ivan Vilata i Balaguer
2010-10-13 20:52         ` Nick Dokos
2010-10-15  6:24           ` Carsten Dominik
2010-10-15 12:22             ` Nick Dokos
2010-10-15 12:31           ` Ivan Vilata i Balaguer

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).