pander icon indicating copy to clipboard operation
pander copied to clipboard

#362 update jQuery to 3.6.0

Open hedsnz opened this issue 1 year ago • 1 comments

  • Download jQuery 3.6.0 from source (please run tools/update-jquery.R yourself to verify that the source is correct). This method of updating dependencies is based on what Shiny currently does (e.g., https://github.com/rstudio/shiny/blob/main/tools/updatejQuery.R)
  • Remove slimbox2.js

Obviously there is no jquery.min.js in the Rapporter CDN currently, so the only way to reference the updated jQuery is, for example, by setting portable.html = FALSE in Pandoc.brew. This is some example code from the README that I used to check:

library(pander)

text <- paste('# Header',
              '',
              'What a lovely list:\n<%= as.list(runif(10)) %>',
              'A wide table:\n<%= mtcars[1:3, ] %>',
              'And a nice chart:\n\n<%= plot(1:10) %>',
              sep = '\n')
Pandoc.brew(text = text, output = tempfile(), convert = 'html', portable.html = FALSE)

Note that the relevant code from convert.R is this, which uses local JavaScript source files instead of from the CDN:

if (portable.html) {
    ch <- ho
} else {
    ch <- gsub('http://cdn.rapporter.net/pander', system.file('includes/', package = 'pander'), ho)
}

When portable.html = TRUE (default), the example gives several errors in the browser console (unable to access the CDN). When it's set to FALSE, there are fewer errors because it uses local versions, but there is one that may be related to the update of jQuery:

Uncaught TypeError: e.indexOf is not a function

This error points to line 84 in custom.js, which is this:

$(window).load(function() {
# ...

The other side effect of this is that the page items load horizontally, instead of vertically. I'm guessing this is to do with the removal of slimbox but I'm not sure.

Sorry that I can't provide a fully functional patch, but hopefully this is a good start!

Thanks.

hedsnz avatar Mar 01 '23 21:03 hedsnz

Thanks a ton, this is indeed a great start!!

I think I can update the CDN (the rapporter.net service has been shut down a long time ago), but probably better to remove that functionality altogether.

I can take this from here, thanks again.

daroczig avatar Mar 03 '23 10:03 daroczig