-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: missing toolbar in self_contained gitbook with pandoc 2.7.3 #739
Comments
Could you provide a minimal reproducible example as required in the issue guide? It will be great if you can provide the HTML output, too (you can upload them as a zip archive here). |
bookdown-demo-master-html-selfcontained.zip This is the reproducible example that I just made from scratch:
In the zip file the html files of the book are included. |
Perfect. Could you also provide a copy of the output with the lower version of Pandoc so that I can compare it with the buggy output produced by Pandoc 2.7? Thanks! |
bookdown-demo-master-html-selfcontained_pandoc_old.zip These are the (selfcontained) files generated by "pandoc_old" included in RStudio 1.1.4. Cheers |
@yihui is there news? how could i help you to solve the issue? |
Sorry, but I won't have time for this issue this year (I have to focus on another project). I would start from comparing the output .html files generated by the different versions of Pandoc and see what's going on. |
@yihui Thanks for the update. Fair enough. At the moment I'm fine with working on the old pandoc and looking forward to get rid of the obstacle to create a standalone version. |
I haven't seen this issue. I'll have a look. |
@Pindar777 I can reproduce the issue for R 3.6.1, the latest CRAN versions of bookdown, rmarkdown et alii and Pandoc >= 2.0.6, see https://rlesur.gitlab.io/bookdown-issue739/. But I am struggling to reproduce the self contained gitbook with "old Pandoc". |
@RLesur Thank you for your efforts. Well, I think I know what you mean: it takes ages!
|
@Pindar777 Thanks a lot! This is super useful. I can reproduce with "old Pandoc". It seems to be related to Pandoc 2. I haven't spotted the issue yet. Will dive into this. |
@RLesur Good to hear! |
I think I've spotted the problem. Before Pandoc 2, JS scripts (and CSS stylesheets) were encoded in base64 for self contained HTML documents. Pandoc 2 has a different behavior (see jgm/pandoc#3423).
Lines 130 to 139 in 2227cd6
The trick used to detect JS scripts for self-contained documents does not work anymore for Pandoc 2. Therefore, the JS scripts are not moved at the end of the HTML documents and the gitbook JS library fails. |
@RLesur That's it! |
Thanks for the investigation @RLesur ! However, you the expert in JS, and you could have other idea than identify with a regex, and move at the end to deal with
What do you think ? |
I'm not a JS expert but I know that there exists some JS alternatives to ensure that the scripts run after the DOM is loaded. |
I continued to dig a bit on how to solve this with regex. Pandoc changes effects are that now js scripts are included as is inside I think there is a choice that has to be done, on how to deal with this the clever way for bookdown future. |
Lua filters are useful to modify the AST. One also can modify metadata but I'm not sure that moving JS scripts from |
As investigated in rstudio#739, pandoc2 modified the way it handles js scripts in self contained document. They are not always base64 encoded by default, and are rather included in `<script>` tags as-is. This means that for gitbook post processing, multiline blocks must be identified and moved.
A quick solution using regex as of now in bookdown is quite easy to implement in fact. I'll work on that. For the long run and prevent this type of issue, changing to another solution can be interesting but at the cost of rewriting some part of bookdown 😁 I'll open a PR when work is ready in my branch |
@Pindar777 you can test with the PR I just opened. remotes::install_github("rstudio/bookdown#784") In our tests with @RLesur, it seems to work well now |
I didn't read this issue or the PR #784 carefully, but if we have to make a choice between Pandoc 1.19 and 2.x, I'll be totally happy to drop the support for Pandoc 1.19 in bookdown (I'd be more conservative only in the rmarkdown package). |
IMO, this issue does not require to make a choice between Pandoc 1.19 and 2.x. @cderv's PR works for both. |
…document (#784) allow to move multiline script node in html As investigated in #739, Pandoc 2 modified the way it handles js scripts in self contained document. They are not always base64 encoded by default, and are rather included in `<script>` tags as-is. This means that for gitbook post processing, multiline blocks must be identified and moved.
Excellent! Just merged the PR. Thanks again for the wonderful help! |
@cderv I just complied the standalone gitbook with pandoc 2.7.3: It is working perfectly and blazing fast! Thanks for the help. |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
After updating the RStudio-Version and at the same time the pandoc version my self_contained gitbook got knitted without toolbar. I could reproduce the error with pandoc 2.7.3 and visual studio code bookdown extension.
After downgrading to a pandoc version included in RStudio 1.14 the error was solved.
The text was updated successfully, but these errors were encountered: