I am trying to have basic collapsing/folding functionality for sections in the HTML file that has been exported from org-mode, since the files I want to share are very large. I am using Emacs 26.2 (9.0) and Org 9.1.9 on a Mac. I am not able to get this previous solution to work in 2019.

This seems like a built in feature but it seems like the underlying javascript code has a bug. I also saw another tool mentioned on the mailing lists, but without any examples I don't know how apply it to a specific org file I have.

For example, the following file is converted to HTML here

#+Title+: JS test
#+INFOJS_OPT: path:/~ksb/js/org-info.js
#+INFOJS_OPT: toc:nil ltoc:nil view:overview mouse:underline
#+INFOJS_OPT: home:https://orgmode.org buttons:nil
* Chapter 1
** Section 1
*** Part 1
 - csp
** Section 2
 - cs2p

I have a freshly-downloaded copy of js/org-info.js.

UPDATE: there is a javascript error being raised by org-info.js

Uncaught TypeError: Cannot read property 'cloneNode' of undefined
    at Object.initFromTOC (org-info.js:82)
    at Object.init (org-info.js:49)
    at OrgHtmlManagerLoadCheck (org-info.js:289)
    at <anonymous>:1:1

The path to your org-info.js file does not seem to match where the file actually is.

You have the file at: http://web.stanford.edu/~ksb/js/org-info.js

But your example page is expecting it to be at: http://web.stanford.edu/~ksb/docs/js/org-info.js

If you move the js folder to the docs folder, or change

#+INFOJS_OPT: path:js/org-info.js


 #+INFOJS_OPT: path:/js/org-info.js

it should work.

  • Thanks! though when I add the forward slash, I see no change in behavior (the hyperlinked files have been updated). Normally, whenever "path" does not point to the actual org-info.js file (e.g. I add an arbitrary typo), the .html file just looks empty, so perhaps path:js/org-info.js and path:/js/org-info.js are actually both pointing to the correct path. – ksb Nov 15 '19 at 6:09
  • Oh, hmm, how about if you try #+INFOJS_OPT: path:/~ksb/js/org-info.js? – ngm Nov 15 '19 at 14:17
  • When I do that, I get the same behavior as any incorrect path to org-info.js (e.g. the same result as #+INFOJS_OPT: path:/js/ooo-oooo.js). The page is basically blank (html,org). – ksb Nov 15 '19 at 15:32
  • Hmm, it looks as if it's finding the file now, but it's resulting in a JavaScript error. TypeError: k.T is undefined. Not sure what that problem would be! I might have a try at recreating it later on. – ngm Nov 15 '19 at 15:41
  • I see now from inspecting the webpage. The error I see in "console" is Uncaught TypeError: Cannot read property 'cloneNode' of undefined - I'm a bit clueless about javascript but this brings me much closer to a solution, thanks! – ksb Nov 15 '19 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.