rbookdowngitbook

How to use gitbook plugin in gitbook style bookdown


There is a simple procedure to put buttons for copying code of gitbooks. What would be the way to do that in a bookdown?

# install npm
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

# install gitbook builder
sudo npm install -g gitbook
sudo npm install -g gitbook-cli

# git clone gitbook "example" repository
git clone ...

cd gitbook/
npm init

# Install plugin to add clipboard button for code 
# https://www.npmjs.com/package/gitbook-plugin-copy-code-button
npm install gitbook-plugin-copy-code-button

Create index.md

and make book.json:

{
"structure": {
    "readme": "index.md"
},
  "plugins": ["copy-code-button"]
}

Finally, gitbook build .

enter image description here


Solution

  • We just added the Copy button in the development version of bookdown. You may test it via

    remotes::install_github('rstudio/bookdown')
    

    To answer your original question: currently there is no way to use gitbook plugins in bookdown.