Rapporter / pander

An R Pandoc Writer: Convert arbitrary R objects into markdown
http://rapporter.github.io/pander/
Open Software License 3.0
294 stars 66 forks source link

#362 update jQuery to 3.6.0 #364

Open hedsnz opened 1 year ago

hedsnz commented 1 year ago

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.

daroczig commented 1 year ago

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.