emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* bug in orgmode parsing of results
@ 2016-12-27 13:36 daimrod
  2016-12-27 18:09 ` Nicolas Goaziou
  2016-12-27 18:11 ` Charles C. Berry
  0 siblings, 2 replies; 5+ messages in thread
From: daimrod @ 2016-12-27 13:36 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1655 bytes --]

Hi,

I've found what I think is a bug in orgmode parsing.
When the following file is parsed :

* Test
#+BEGIN_SRC emacs-lisp :exports results :results raw drawer
(format "- Test2")
#+END_SRC

#+RESULTS:
:RESULTS:
- Test2
:END:

The truncated result of `org-element-parse-buffer' is :
(src-block
 (:language \"emacs-lisp\" :switches nil :parameters \":exports results
:results raw drawer\" :begin 8 :end 98 :number-lines nil
:preserve-indent nil :retain-labels t :use-labels t :label-fmt nil
:value \"(format \\\"- Test2\\\")\\n\" :post-blank 1 :post-affiliated 8
:parent #2))
(drawer
 (:begin 98 :end 133 :drawer-name \"RESULTS\" :contents-begin 119
:contents-end 127 :post-blank 0 :post-affiliated 109 :results
         (\"\")
         :parent #2))

That is, it generates a DRAWER, which seems correct.

However, when the following file is parsed :

* Test
#+BEGIN_SRC emacs-lisp :exports results :results raw drawer
(format "* Test2")
#+END_SRC

#+RESULTS:
:RESULTS:
* Test2
:END:

The (truncated) result of `org-element-parse-buffer' is :
(src-block
 (:language \"emacs-lisp\" :switches nil :parameters \":exports results
:results raw drawer\" :begin 8 :end 98 :number-lines nil
:preserve-indent nil :retain-labels t :use-labels t :label-fmt nil
:value \"(format \\\"* Test2\\\")\\n\" :post-blank 1 :post-affiliated 8
:parent #2))
(paragraph
 (:begin 98 :end 119 :contents-begin 109 :contents-end 119 :post-blank 0
:post-affiliated 109 :results
         (\"\")
         :parent #2)
 #(\":RESULTS:\\n\" 0 10
   (:parent #3)))

That is, it generates a PARAGRAPH which seems incorrect.

WDYT?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 829 bytes --]

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

* Re: bug in orgmode parsing of results
  2016-12-27 13:36 bug in orgmode parsing of results daimrod
@ 2016-12-27 18:09 ` Nicolas Goaziou
  2016-12-28 13:56   ` daimrod
  2016-12-27 18:11 ` Charles C. Berry
  1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2016-12-27 18:09 UTC (permalink / raw)
  To: daimrod; +Cc: emacs-orgmode

Hello,

daimrod <daimrod@gmail.com> writes:

> #+RESULTS:
> :RESULTS:
> * Test2
> :END:
>
[...]

> (paragraph
>  (:begin 98 :end 119 :contents-begin 109 :contents-end 119 :post-blank 0
> :post-affiliated 109 :results
>          (\"\")
>          :parent #2)
>  #(\":RESULTS:\\n\" 0 10
>    (:parent #3)))
>
> That is, it generates a PARAGRAPH which seems incorrect.

The parser is correct. A drawer cannot contain a headline.

Regards,


-- 
Nicolas Goaziou

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

* Re: bug in orgmode parsing of results
  2016-12-27 13:36 bug in orgmode parsing of results daimrod
  2016-12-27 18:09 ` Nicolas Goaziou
@ 2016-12-27 18:11 ` Charles C. Berry
  2016-12-28 14:03   ` daimrod
  1 sibling, 1 reply; 5+ messages in thread
From: Charles C. Berry @ 2016-12-27 18:11 UTC (permalink / raw)
  To: daimrod; +Cc: emacs-orgmode

On Tue, 27 Dec 2016, daimrod wrote:

> Hi,
>
> I've found what I think is a bug in orgmode parsing.
> When the following file is parsed :
>
> * Test
> #+BEGIN_SRC emacs-lisp :exports results :results raw drawer
> (format "- Test2")
> #+END_SRC
>
> #+RESULTS:
> :RESULTS:
> - Test2
> :END:
>

[snip]

>
> That is, it generates a DRAWER, which seems correct.
>
> However, when the following file is parsed :
>
> * Test
> #+BEGIN_SRC emacs-lisp :exports results :results raw drawer
> (format "* Test2")
> #+END_SRC
>
> #+RESULTS:
> :RESULTS:
> * Test2
> :END:
>

[deleted]

> That is, it generates a PARAGRAPH which seems incorrect.
>
> WDYT?
>

What I think is that you should run org-lint on your document. It will say 
something like this (but with different line numbers):

   Line Trust Warning
      2 low   Forbidden combination in header ":results": raw, drawer
     12 low   Forbidden combination in header ":results": raw, drawer
     17 low   Possible incomplete drawer ":RESULTS:"

The last one should catch your eye.

If you want to generate results that have lines that start with `*' you 
need to protect them. A good way to do this is to wrap them in a src block 
or export block like this:

#+BEGIN_SRC emacs-lisp :exports results :wrap export latex
(format "* Test2")
#+END_SRC

HTH,

Chuck

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

* Re: bug in orgmode parsing of results
  2016-12-27 18:09 ` Nicolas Goaziou
@ 2016-12-28 13:56   ` daimrod
  0 siblings, 0 replies; 5+ messages in thread
From: daimrod @ 2016-12-28 13:56 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 561 bytes --]



On 12/27/16 19:09, Nicolas Goaziou wrote:
> Hello,
> 
> daimrod <daimrod@gmail.com> writes:
> 
>> #+RESULTS:
>> :RESULTS:
>> * Test2
>> :END:
>>
> [...]
> 
>> (paragraph
>>  (:begin 98 :end 119 :contents-begin 109 :contents-end 119 :post-blank 0
>> :post-affiliated 109 :results
>>          (\"\")
>>          :parent #2)
>>  #(\":RESULTS:\\n\" 0 10
>>    (:parent #3)))
>>
>> That is, it generates a PARAGRAPH which seems incorrect.
> 
> The parser is correct. A drawer cannot contain a headline.

Hmm, OK.

> Regards,
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 829 bytes --]

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

* Re: bug in orgmode parsing of results
  2016-12-27 18:11 ` Charles C. Berry
@ 2016-12-28 14:03   ` daimrod
  0 siblings, 0 replies; 5+ messages in thread
From: daimrod @ 2016-12-28 14:03 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1933 bytes --]



On 12/27/16 19:11, Charles C. Berry wrote:
> On Tue, 27 Dec 2016, daimrod wrote:
> 
>> Hi,
>>
>> I've found what I think is a bug in orgmode parsing.
>> When the following file is parsed :
>>
>> * Test
>> #+BEGIN_SRC emacs-lisp :exports results :results raw drawer
>> (format "- Test2")
>> #+END_SRC
>>
>> #+RESULTS:
>> :RESULTS:
>> - Test2
>> :END:
>>
> 
> [snip]
> 
>>
>> That is, it generates a DRAWER, which seems correct.
>>
>> However, when the following file is parsed :
>>
>> * Test
>> #+BEGIN_SRC emacs-lisp :exports results :results raw drawer
>> (format "* Test2")
>> #+END_SRC
>>
>> #+RESULTS:
>> :RESULTS:
>> * Test2
>> :END:
>>
> 
> [deleted]
> 
>> That is, it generates a PARAGRAPH which seems incorrect.
>>
>> WDYT?
>>
> 
> What I think is that you should run org-lint on your document. It will
> say something like this (but with different line numbers):
> 
>   Line Trust Warning
>      2 low   Forbidden combination in header ":results": raw, drawer
>     12 low   Forbidden combination in header ":results": raw, drawer
>     17 low   Possible incomplete drawer ":RESULTS:"
> 
> The last one should catch your eye.

Didn't know about org-lint. Thanks.

> If you want to generate results that have lines that start with `*' you
> need to protect them. A good way to do this is to wrap them in a src
> block or export block like this:
> 
> #+BEGIN_SRC emacs-lisp :exports results :wrap export latex
> (format "* Test2")
> #+END_SRC

The thing about :wrap export html is that I've to generate the HTML
myself, whereas when I export the :RESULTS: drawer, org-mode generates
the HTML. AFAIK there is no export block for org (no begin_export org).

As a workaround I can always use `:results raw` but then it can not
replace the result automatically. However, that's not a problem for my
use case I think...

Thanks for your help.

Best,


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 829 bytes --]

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

end of thread, other threads:[~2016-12-28 14:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-27 13:36 bug in orgmode parsing of results daimrod
2016-12-27 18:09 ` Nicolas Goaziou
2016-12-28 13:56   ` daimrod
2016-12-27 18:11 ` Charles C. Berry
2016-12-28 14:03   ` daimrod

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