sch0lars · 2022-06-23 23:55
I would like to include some rendered HTML generated from `groovydoc` into an org document before exporting it to a PDF. Is this possible? Something like
#+BEGIN_EXPORT html
[[./index.html]]
#+END_EXPORT
I have tried `#+INCLUDE: "index.html" export html` and it is blank, but `#+INCLUDE: "index.html" src html` returns the source. Could this be due to JavaScript being used to generate the Groovy documentation?
polaris64 · 2022-06-24 11:34
I'm not sure if it's just the example you've given, but it seems to be missing the closing quote after the filename.
For me this works (in an Org mode buffer): -
The contents of the following HTML file should be inserted verbatim at this point:
#+INCLUDE: "./test.html" export html
The best way of verifying is to run `org-export-dispatch` (`C-c C-e`) and then export to a HTML buffer (`h H`). Then take a look at the generated HTML and see if the unescaped contents of index.html are indeed there.
Also, it could be that index.html contains a full HTML page, not just a section of HTML. Remember that `#+INCLUDE` blindly inserts the entire file contents into the document at that point, so it might result in invalid HTML depending on what's in index.html.
sch0lars · 2022-06-24 11:57
Oh yeah, sorry. That was my mistake. I typed this on my phone. The quotes are correct in the org file.
The Groovy documentation appears to be pre-rendered JavaScript. I’m not sure if Org-Mode is capable of rendering the HTML from the JavaScript like the browser, but I would assume there’s some kind of configuration that would allow it.
I’m fairly new to using the more advanced features of Org-Mode, but it’s made documenting things at work (and sharing the documentation) way more efficient, so it would be nice if there was a way to insert the generated groovydoc directly into a section within the org file. If not, I can always just link to it.
AblatedSprocket · 2022-06-24 12:12
I don't think Org export has the capability to evaluate JavaScript to generate HTML. It will take whatever JavaScript is on the page and copy it to the new document, along with the rest of the file. Depending on the JavaScript, you might not be able to tell the difference. You would probably want a post-export hook that takes script tags and moves them to the bottom of the document.
yantar92 · 2022-06-25 12:23
You can use js code blocks that will be executed during export. Just make sure that you have ob-js.el loaded. See https://orgmode.org/manual/Exporting-Code-Blocks.html#Exporting-Code-Blocks