README.md

wikipediapreview

Wikipedia Preview for R Markdown documents.

| Format/Generator | Compatibility | |:-----------------|:--------------| | blogdown blog/website | ✅ Confirmed | | bookdown website | ❔ Unknown | | distill article | ✅ Confirmed | | distill blog/website | ❔ Unknown (but probably works) | | HTML Vignette/Document | ✅ Confirmed | | pkgdown article | ✅ Confirmed | | Quarto HTML documents | ✅ Confirmed | | Quarto blog/website | ✅ Confirmed | | Quarto presentation | ✔️ Confirmed BUT using alternative styling is not recommended | | Reveal.js presentation | ✔️ Confirmed BUT using alternative styling is not recommended | | xaringan presentation | ✔️ Confirmed BUT {.wiki} styling does not work |

NOTE: Wikipedia Preview standalone JS component can be used on any website. There is also an official WordPress plug-in.

Installation

You can install the development version of wikipediapreview like so:

# install.packages("remotes")
remotes::install_github("bearloga/wikipediapreview-r")

Example

To initialize include the following anywhere in your R Markdown document:

`r wikipediapreview::wp_init()`

If you prefer, you can initialize using a designated chunk instead:

```{r wp-init, results='asis', echo=FALSE}
library(wikipediapreview)
wp_init()
```

Links to Wikipedia articles in your R Markdown document will automatically have popup cards showing your readers a preview of the linked article:

Demonstration of Wikipedia Preview on a rendered R Markdown vignette

1.8.0

This package uses version 1.8.0 of Wikipedia Preview while the latest version (as of 2024-06-23) is 1.11.0 and includes awesome improvements like multiple color schemes (night/dark mode).

However, starting with 1.9.0, the maintainers of the library have been distributing a CommonJS version (.cjs). Unpkg has an unresolved issue where it does not correctly set the content type of .cjs files -- it serves them as "text/plain" instead of "application/javascript" -- which sets off an "blocked due to MIME type mismatch (X-Content-Type-Options: nosniff)" error when the browser tries to load it from unpkg's servers.

Until that issue is resolved, this package cannot use the latest version of Wikipedia Preview library.



bearloga/wikipediapreview-r documentation built on June 29, 2024, 1:37 a.m.