jkitchin / ox-ipynb

org-mode exporter to Jupyter notebooks
170 stars 39 forks source link

org headlines cause error #16

Closed ferrinm closed 5 years ago

ferrinm commented 5 years ago

First off, many thanks for building this tool; I'm very excited to use it!

I was unable to export your example.org, so I think I narrowed the problem down to the headlines. A minimal org file with an ipython block exports successfully:

#+BEGIN_SRC ipython 
a = 'test'
a
#+END_SRC

#+RESULTS:
: # Out[11]:
: : 'test'

However, as soon as I add a headline:

* headline
#+BEGIN_SRC ipython 
a = 'test'
a
#+END_SRC

#+RESULTS:
: # Out[11]:
: : 'test'

I get the error: Wrong number of arguments: (0 . 0), 1

The debugger backtrace shows:

Debugger entered--Lisp error: (wrong-number-of-arguments (0 . 0) 1)
  org-get-tags(1)
  #f(compiled-function (hl) #<bytecode 0x43a50b81>)((headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#("headline" 0 8 (:parent (headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#0) :parent (org-data nil #2)) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #2) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #3)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #3))))))) :parent (org-data nil #1)) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #1) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #2)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #2)))))
  #f(compiled-function (--data) #<bytecode 0x43a50b8d>)((headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#("headline" 0 8 (:parent (headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#0) :parent (org-data nil #2)) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #2) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #3)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #3))))))) :parent (org-data nil #1)) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #1) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #2)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #2)))))
  mapc(#f(compiled-function (--data) #<bytecode 0x43a50b8d>) ((headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#("headline" 0 8 (:parent (headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#0) :parent (org-data nil #2)) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #2) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #3)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #3))))))) :parent (org-data nil . #1)) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #2) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #3)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #3))))))
  #f(compiled-function (--data) #<bytecode 0x43a50b8d>)((org-data nil (headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#("headline" 0 8 (:parent (headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#0) :parent (org-data nil #2)) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #2) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #3)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #3))))))) :parent #1) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #2) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #3)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #3))))))
  org-element-map((org-data nil (headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#("headline" 0 8 (:parent (headline (:raw-value "headline" :begin 1 :end 92 :pre-blank 0 :contents-begin 12 :contents-end 92 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#0) :parent (org-data nil #2)) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #2) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #3)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #3))))))) :parent #1) (section (:begin 12 :end 92 :contents-begin 12 :contents-end 92 :post-blank 0 :post-affiliated 12 :parent #2) (src-block (:language "ipython" :switches nil :parameters nil :begin 12 :end 57 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "a = 'test'\na\n" :post-blank 1 :post-affiliated 12 :parent #3)) (fixed-width (:begin 57 :end 92 :value "# Out[11]:\n: 'test'\n" :post-blank 0 :post-affiliated 68 :results ("") :parent #3))))) headline #f(compiled-function (hl) #<bytecode 0x43a50b81>))
  ox-ipynb-export-to-buffer()
  ox-ipynb-export-to-ipynb-buffer(nil nil nil nil nil)
  ox-ipynb-export-to-ipynb-file(nil nil nil nil)
  org-export-dispatch(nil)
  funcall-interactively(org-export-dispatch nil)
  call-interactively(org-export-dispatch nil nil)
  command-execute(org-export-dispatch)
jkitchin commented 5 years ago

I can't reproduce this error. I wonder if this is an org-version issue. I feel like I remember that the signature for org-tags may have changed. It looks like org-get-tags is the problem for you. Some questions:

  1. What version of org-mode are you using? M-x org-version
  2. what does C-h f org-get-tags tell you about the function signature?
ferrinm commented 5 years ago
  1. Org mode version 9.1.14
  2. I'm not familiar with what a "function signature" is, but here is what C-h f org-get-tags gives me:
    
    org-get-tags is a compiled Lisp function in ‘org.el’.

(org-get-tags)

Get the list of tags specified in the current headline.



I'm also using spacemacs, if that matters...
jkitchin commented 5 years ago

That does seem to be the difference. In org-9.2 I see:

org-get-tags is a compiled Lisp function in `org.el'.

(org-get-tags &optional POS LOCAL)

I am not sure what the best way to fix it is, other than updating your org-verison.

ferrinm commented 5 years ago

I upgraded to Org mode version 9.2.1, and the error no longer occurs. Thank you for helping so quickly!