yonicd / slickR

slick carousel htmlwidget for R
https://yonicd.github.io/slickR/
Other
161 stars 14 forks source link

problems with SVG images #39

Open dan-reznik opened 4 years ago

dan-reznik commented 4 years ago

I am trying to create a simple caroussel with slickR and a few SVG images but I get this error after the call to slickR::slickR(...)

Error in checkStandalone(fL) : SVG not standalone

The thing is my SVG is perfectly "standalone". Indeed, its first few lines are:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="801pt" height="552pt" viewBox="0 0 801 552" version="1.1">
<defs>
<g>
<symbol overflow="visible" id="glyph0-0">
<path style="stroke:none;" d="M 1.25 0 L 1.25 -15.996094 L 8.75 -15.996094 L 8.75 0 Z M 2.5 -1.25 L 7.5 -1.25 L 7.5 -14.746094 L 2.5 -14.746094 Z "/>
</symbol>

Checkin on your code under readImage.R, the above error seems to be produced by a line which attempts to locate the string "xmlns" on the first line of the SVG. notice above this is found on the SECOND LINE. Should this function be relaxed to find "xmlns" on any few first lines of the .svg?

checkStandalone <- function(x){
  if(!grepl("xmlns", readLines(x, n = 1))){
    stop('SVG not standalone')
  }else{
    TRUE
  } 
}
yonicd commented 4 years ago

you are welcome to PR an update. I do not know if i will get to a patch today

yonicd commented 4 years ago

Can you please attach an example of a svg you are using so I can test on it?

Thanks

yonicd commented 4 years ago

Try this patch. https://github.com/metrumresearchgroup/slickR/commit/43a6a4e75e30e7b9b6a61993ae789410e1b89475

dan-reznik commented 4 years ago

I tried it but GitHub didn't let me. Here it is in this email

On Fri, Feb 28, 2020 at 8:17 AM yonicd notifications@github.com wrote:

Can you please attach an example of a svg you are using so I can test on it?

Thanks

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/metrumresearchgroup/slickR/issues/39?email_source=notifications&email_token=AD32VFSZPRA4UZITPYU5FJTRFDXFNA5CNFSM4K44XRRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENIF3WQ#issuecomment-592469466, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD32VFR7TLIICQZ5OMRKMU3RFDXFNANCNFSM4K44XRRA .

yonicd commented 4 years ago

I didn't get an email.

can you cat(readLines(PATH_TO_FILE)) and paste in the output

thanks

yonicd commented 4 years ago

you can use this commit (https://github.com/metrumresearchgroup/slickR/commit/e8d3e0e7d2278eebe56ff528e5b6204d6d957da5) to test your file. it solves the problem a different way that is more robust

remotes::install_github('metrumresearchgroup/slickR@e8d3e0e')

ht @dmi3kno

dcaud commented 3 years ago

Hi. I'm having this problem, and the commit you referenced fixes it.

Can this be added into the master branch?