-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search function doesn't work #12
Comments
You don't need What do you mean by "doesn't work"? No search button? Typed in the search box but nothing happened? A screenshot will be helpful. Are you viewing the HTML output in RStudio Viewer or an external browser? Searching won't work for the latter case unless you serve the HTML output with a web server. |
Oh, OK, got it. Viewing in external browser--so it won't work locally. Sorry! |
You can serve the book locally and search button will function, e.g. use the addin "Preview Book": https://bookdown.org/yihui/bookdown/rstudio-ide.html |
@yihui it does seem that the search option is showing some buggy behavior. I'm hosting a book on: https://shklinkenberg.github.io/Interactive_Teaching_Techniques/index.html# I got search working by first building the book and then saving the _output.yml file by making a minor change (adding a white space). Then without rebuilding and committing and pushing this to github, it worked. But if I rebuild, then clicking the search icon does not make the search field appear. I'm not testing local, only on github.io |
Hi @yihui, I am also experiencing some problems with the search option. I have a page https://jura.tepedu.dk |
@cphthomas Please make sure you are using the latest version of bookdown to compile the book. |
Hi @yihui, thanks for your quick reply :O) I'm building the book on rstudio.cloud using: |
@cphthomas 0.9 is not the latest: https://cran.rstudio.com/web/packages/bookdown/ |
Hi @yihui, thanks a lot, and thank you for a wonderful package :O) |
I am encountering this issue with version 0.20 when I render https://github.com/yihui/bookdown-minimal locally. Can anyone else reproduce this? Related: ropensci-books/drake#165. |
@wlandau It's not reproducible to me. Please see #12 (comment). The search button won't work if you open index.html. You have to view the book via a server. |
Thanks Yihui, all my search bars work locally when I run a server. |
In both my case and that of @ShKlinkenberg, I think this is caused by an invalid In my case, I think the problem is that So I think somewhere in the stack, the text in |
Now it should be fixed via remotes::install_github('rstudio/bookdown') Thanks! |
@ShKlinkenberg Good to know! I'll make a CRAN release in a couple of weeks. Thanks for confirming! |
does search bar support all languages, i did some test, searching Chinese Characters, doesn't seem to work |
i did some research i found this thread rstudio/bookdown#387 conclusion seem to be doesn't work with CJK characters, and it's related to gitbook implementation also found this https://github.com/rstudio/bookdown/blob/ee96e467b021045a858f3fb198df27965146f287/inst/resources/gitbook/js/plugin-search.js#L8-L29 function loadIndex(data) {
// [Yihui] In bookdown, I use a character matrix to store the chapter
// content, and the index is dynamically built on the client side.
// Gitbook prebuilds the index data instead: https://github.com/GitbookIO/plugin-search
// We can certainly do that via R packages V8 and jsonlite, but let's
// see how slow it really is before improving it. On the other hand,
// lunr cannot handle non-English text very well, e.g. the default
// tokenizer cannot deal with Chinese text, so we may want to replace
// lunr with a dumb simple text matching approach.
index = lunr(function () {
this.ref('url');
this.field('title', { boost: 10 });
this.field('body');
});
data.map(function(item) {
index.add({
url: item[0],
title: item[1],
body: item[2]
});
});
} seems to be a functionality related to |
interesting so it seems to be the lunr.js doesn't support CJK - olivernn/lunr.js#173 there's this repo that support multi language but i don't see Chinese https://github.com/MihaiValentin/lunr-languages there's this https://github.com/Wiredcraft/lunr-chinese, this one might work for chinese another possible solution is https://github.com/krisk/fuse (fuse.js) this works well with all languages when i find some time I will submit a PR |
IMO fuse.js is definitely something we should consider. This was mentioned in rstudio/bookdown#975 Before doing anything PR related, you should open an issue so that we can discuss this type of change. Thanks for sharing this and the suggestion BTW ! |
Compiling this example doesn't allow search to work.
Saved and extracted zip file.
Opened project in R Studio 1.0.44 (with R 3.3.1).
Opened index.Rmd.
Clicked Build Book.
Site and pdf are created just fine, but search doesn't work. Other menu bar buttons do work.
Adding
search: yes
to _output.yml doesn't let it work.Played with other bookdown books, search does work. Copied those _output.yml files' content over, search still doesn't work. Not sure where to look next to allow search to work.
The text was updated successfully, but these errors were encountered: