knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Initialize Wikipedia Preview by including the following inline code anywhere in your R Markdown document:
`r wikipediapreview::wp_init()`
Note: If you prefer to have a designated chunk, initialize with the following code instead:
```r library(wikipediapreview) wp_init() ```
wikipediapreview::wp_init()
The library automatically detects Wikipedia links.
Source:
Sampling via [MCMC](https://en.wikipedia.org/wiki/Markov_chain_Monte_Carlo)
Output:
Sampling via MCMC
You can also make those links stand out and appear different from non-Wikipedia links using the built-in style:
Source:
[Stan](https://mc-stan.org/) samples via [HMC](https://en.wikipedia.org/wiki/Hamiltonian_Monte_Carlo){.wiki}
Output:
Wikipedia Preview works with all the language editions of Wikipedia.
Source:
At the time of writing this vignette the article on [Bayesian inference](https://en.wikipedia.org/wiki/Bayesian_inference){.wiki} is available in 30 languages, including: - Arabic: [استدلال بايزي](https://ar.wikipedia.org/wiki/%D8%A7%D8%B3%D8%AA%D8%AF%D9%84%D8%A7%D9%84_%D8%A8%D8%A7%D9%8A%D8%B2%D9%8A){.wiki} - French: [Inférence bayésienne](https://fr.wikipedia.org/wiki/Inf%C3%A9rence_bay%C3%A9sienne){.wiki} - Japanese: [ベイズ推定](https://ja.wikipedia.org/wiki/%E3%83%99%E3%82%A4%E3%82%BA%E6%8E%A8%E5%AE%9A){.wiki}
Output:
At the time of writing this vignette the article on Bayesian inference{.wiki} is available in 30 languages, including:
The default styling is the one provided and used by Wikimedia's Inuka team which developed Wikipedia Preview. The author of this package prefers a different styling and has made it available via the use_alt_style
flag when initializing:
`r wikipediapreview::wp_init(use_alt_style = TRUE)`
{css, echo=FALSE}
a.wiki-alt {
text-decoration: none;
border-bottom: 1px dotted #0645ad;
}
.wiki-alt::after {
font-family: serif;
content: " W";
vertical-align: super;
font-size: 6pt;
}
Wikipedia links will be marked with a W that looks similar to the Wikipedia logo{.wiki-alt}.
By default wp_init()
will embed the JavaScript code in the page. The Wikipedia Preview JavaScript library is available via a CDN{.wiki} -- specifically unpkg. To use that instead of embedding for bandwidth and performance benefits:
`r wikipediapreview::wp_init(use_unpkg = TRUE)`
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.