Is there anything that could be done here or in a badge package to make badge-handling in the README nicer? For example, a better failure mode when a badge is unavailable.
Intriguing syntax but it's not working for me when primary image is specified the way our svg badges are.
<object data="nope.png" style="width:42px;height:42px;border:0;">
<img src="kitten.jpg" alt="Live badge unavailable." style="width:42px;height:42px;border:0;" >
</object>
nope.png is the primary target and it cannot be found. kitten.jpg is the local fall back.
from https://stackoverflow.com/questions/10772346/display-alternate-image
I can get it to work if the remote badge is png, so maybe there is hope?
A previous discussion of the bad interaction btw specific version of pandoc and shields.io, resolved for codecov specifically by not using shields.io: #36
More wide-ranging badge discussion here: https://github.com/ropensci/unconf17/issues/58
Interesting input from Pandoc maintainer here, a thread about relaxing the self-containedness of html previews of md documents:
https://github.com/rstudio/rmarkdown/issues/1238#issuecomment-361087447
From the pandoc manual:
Elements with the attributedata-external="1"will be left alone; the documents they link to will not be incorporated in the document.
Perhaps we could incorporate the badges this way?
I just tried with two different variations on the badge syntax (putting the data-external="1" attribute in the <a> tag and in the <img>:
<a href="https://travis-ci.org/r-lib/usethis">
<img src="https://travis-ci.org/r-lib/usethis.svg?branch=master" alt="Travis build status" data-external="1"></a>
<a href="https://codecov.io/github/r-lib/usethis?branch=master" data-external="1">
<img src="https://codecov.io/gh/r-lib/usethis/branch/master/graph/badge.svg" alt="Coverage status"></a>
Neither works š. I get this failure when offline:
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS README.md --to html --from markdown_github-ascii_identifiers --output README.html --standalone --self-contained --highlight-style pygments --template /Users/jenny/resources/R/library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/Users/jenny/resources/R/library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none
pandoc: Could not fetch https://travis-ci.org/r-lib/usethis.svg?branch=master
FailedConnectionException2 "travis-ci.org" 443 True getAddrInfo: does not exist (nodename nor servname provided, or not known)
Error: pandoc document conversion failed with error 67
Execution halted
so more investigation needed.
I experience the same issues.
@methodds If you can, you should upgrade Pandoc. That should clear up most badge issues.
I'm leaving this open, because it would be nice to have a strategy that allowed README.Rmd to be previewed w/o an internet connection.
Thanks for the hint, but unfortunately I still have the problem even with the latest pandoc version (2.1.1) :(
/usr/bin/pandoc +RTS -K512m -RTS README.md --to html4 --from gfm-ascii_identifiers --output README.html --standalone --self-contained --highlight-style pygments --template /home/cs/R/x86_64-pc-linux-gnu-library/3.4/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/home/cs/R/x86_64-pc-linux-gnu-library/3.4/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none --metadata pagetitle=PREVIEW
Could not fetch http://www.r-pkg.org/badges/version/stminsights
HttpExceptionRequest Request {
host = "www.r-pkg.org"
port = 80
secure = False
requestHeaders = []
path = "/badges/version/stminsights"
queryString = ""
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
}
ConnectionTimeout
Error: pandoc document conversion failed with error 61
Execution halted
When I render README, I get:
/usr/local/bin/pandoc +RTS -K512m -RTS README.md --to html --from gfm-ascii_identifiers --output README.html --standalone --self-contained --highlight-style pygments --template /Users/jenny/resources/R/library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/Users/jenny/resources/R/library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none --metadata pagetitle=PREVIEW
Why do I have --to html and you have --to html4? Is it possible you need to upgrade rmarkdown and its dependencies?
For me:
packageVersion("rmarkdown")
#> [1] '1.8'
Is this project and README on GitHub somewhere I can see?
Thank you for helping me out :) Yes, the project is on github:
https://github.com/methodds/stminsights
In the current version though, I commented out the badge lines in preparation for a CRAN submission:
````
`
Updating rmarkdown and its dependencies changed--to html```, but unfortunately still doesn't work:
/usr/bin/pandoc +RTS -K512m -RTS README.md --to html --from gfm-ascii_identifiers --output README.html --standalone --self-contained --highlight-style pygments --template /home/cs/R/x86_64-pc-linux-gnu-library/3.4/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/home/cs/R/x86_64-pc-linux-gnu-library/3.4/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none --metadata pagetitle=PREVIEW
Could not fetch http://www.r-pkg.org/badges/version/stminsights
HttpExceptionRequest Request {
host = "www.r-pkg.org"
port = 80
secure = False
requestHeaders = []
path = "/badges/version/stminsights"
queryString = ""
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
}
ConnectionTimeout
Error: pandoc document conversion failed with error 61
Execution halted
Here is my sessionInfo():
sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.3
Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.3 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2 htmltools_0.3.6 tools_3.4.3 yaml_2.1.16 Rcpp_0.12.15
[9] stringi_1.1.6 rmarkdown_1.8 knitr_1.19.2 stringr_1.2.0 digest_0.6.15 evaluate_0.10.1
Oooohh, this badge won't exist until your package gets on CRAN. So this is a known weird state that you just have to endure. Corrected: that is no longer true.
But the badge does exist: https://www.r-pkg.org/badges/version/stminsights.
Wow... I removed the CRAN badge before, but this didn't work, probably because of the old pandoc version. Now it does, thank you! So basically there is no way to show a "not yet on CRAN" badge on github? This would surprise me because patchwork for instance does have the badge on github and it seems to be created with a .Rmdfile. @thomasp85 is using a slightly different syntax though:
[](https://CRAN.R-project.org/package=patchwork
So basically there is no way to show a "not yet on CRAN" badge on github
There is. You should always be able to render README.Rmd --> README.md. If the badge resolves, the image will appear on GitHub.
IME these Pandoc errors are only about creating the html preview for your local enjoyment. Caveat: that is not at all obvious -- it's easy to think that you have failed to knit to .md. It also leaves you in a frustrating situation of not being able to preview the .md locally.
I see, thanks, but as least for me this still does not solve issues related to preparations for a CRAN submission. If I use devtools::release() after rendering with the CRAN badge, the following warning is raised:
Conversion of āREADME.mdā failed:
[WARNING] This document format requires a nonempty <title> element.
Please specify either ātitleā or āpagetitleā in the metadata.
Falling back to āREADMEā
Could not fetch https://travis-ci.org/methodds/stminsights.svg?branch=master
HttpExceptionRequest Request {
host = "travis-ci.org"
port = 443
secure = True
requestHeaders = []
path = "/methodds/stminsights.svg"
queryString = "?branch=master"
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
}
This does not happen if I remove the CRAN badge (and then of course the HTML preview also works).
WARNING] This document format requires a nonempty <title> element.
Please specify either ātitleā or āpagetitleā in the metadata.
Falling back to āREADMEā
This is highly suggestive that you don't have the most recent version of rmarkdown.
https://github.com/rstudio/rmarkdown/issues/1200
I also have a suspicion that rmarkdown may be finding an older version of Pandoc. You might want to place rmarkdown::pandoc_version() in README.Rmd as an experiment.
This is output generated by rendering my README.Rmd and adding syntax as you suggested:
library(rmarkdown)
sessionInfo()
#> R version 3.4.3 (2017-11-30)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Linux Mint 18.3
#>
#> Matrix products: default
#> BLAS: /usr/lib/libblas/libblas.so.3.6.0
#> LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] rmarkdown_1.8
#>
#> loaded via a namespace (and not attached):
#> [1] compiler_3.4.3 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2
#> [5] tools_3.4.3 htmltools_0.3.6 yaml_2.1.16 Rcpp_0.12.15
#> [9] stringi_1.1.6 knitr_1.19.2 stringr_1.2.0 digest_0.6.15
#> [13] evaluate_0.10.1
rmarkdown::pandoc_version()
#> [1] '2.1.1'
It seems like rmarkdown and pandoc versions are both up to date.
Then I'm afraid I do not know what's going on. I note that you originally had trouble with the CRAN badge, but the most recent error is about Travis, in case that helps your troubleshooting. Perhaps that was just intermittent bad luck.
The most recent error is always about the CRAN badge or the badge that comes after the CRAN badge. This is another run:
[WARNING] This document format requires a nonempty <title> element.
Please specify either ātitleā or āpagetitleā in the metadata.
Falling back to āREADMEā
Could not fetch https://www.r-pkg.org/badges/version-ago/stminsights
HttpExceptionRequest Request {
host = "www.r-pkg.org"
port = 443
secure = True
requestHeaders = []
path = "/badges/version-ago/stminsights"
queryString = ""
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
}
Anyway, thank you for trying to help me multiple times! If I find a solution, I let you know.
@cschwem2er have you figured it out? I have the same R CMD CHECK warnings at the CRAN infrastructure for incoming checks you outlined and I don't know what to do. Neither travis, appveyor or r-hub give me these warnings. Did removing all badges help?
Unfortunately I still do not have a solution other than removing the badges for the CRAN submission and readding them manually afterwards :/
Thanks. Ok, but it has worked for styler 1.1.0 š¾.
I think this is both largely resolved and outside the scope of usethis.
@cschwem2er have you figured it out? I have the same R CMD CHECK warnings at the CRAN infrastructure for incoming checks you outlined and I don't know what to do. Neither travis, appveyor or r-hub give me these warnings. Did removing all badges help?
Check if any of your badges names (if files) gets matched by your patterns in .RbuildIgnore
Most helpful comment
I see, thanks, but as least for me this still does not solve issues related to preparations for a CRAN submission. If I use
devtools::release()after rendering with the CRAN badge, the following warning is raised:This does not happen if I remove the CRAN badge (and then of course the HTML preview also works).