2

I have not been able to debug why the HTML generated from my bookdown

  1. only displays the search button on Chrome (not in Firefox or Safari),
  2. doesn't do anything in Chrome even though CTRL-F does, and
  3. only searches the local page rather than the book as a whole when I use CTRL-F.

Some of the published Rmarkdown books behave differently. For instance, clicking the search icon in R for Data Science and Authoring Books with R Markdown pop up a search box in Safari above the table of contents in both Safari and Chrome, whereas CTRL-F pops up the local page search. There are no arrows with which to page through results---I need to use the up/down arrow keys on my keyboard. This behavior would be better than what I've been able to achieve, but I do not know what I need to include to make it happen.

My example is book length, but it's all on the develop branch of the stan-dev/stan repo on GitHub. If you clone that repo, the doc can be made with

> make doc/reference-manual/index.html

and the index will be in that location.

Edit: I tried replacing the bookdown::gitbook config with an exact copy of the one in the manual and it still didn't produce a working search button.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
Bob Carpenter
  • 3,613
  • 1
  • 20
  • 13

2 Answers2

3

Searching in bookdown's gitbook format is implemented via lunr.js, and does not rely on an external searching service. Your book content is written to a local JSON file, which lunr.js will query as you type in the search box.

The short answer to your question is that you need to serve your book through an HTTP server (because your browser cannot read a JSON file through the file:// protocol). One way to do that is bookdown::serve_book().

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
  • Thanks. That answers my questions and is good news. I mainly want to host the docs on our server, and it's nice to know I can view it locally before pushing. – Bob Carpenter Jul 23 '18 at 23:34
0

I would like to say that the "magnifying glass" (search tool) works fine after bookdown::serve_book(); it is generated one html, that still works fine, but when the html is transported to github, the search tool disappears, as well as the arrow (carousel) keys; these are keys are substituted by one light square that is functional, like the arrows got a "transparent" colour. I have added to the proper docs folder on github the style.css.

C Lederman
  • 19
  • 4