Comments (21)
IMO fuse.js is definitely something we should consider. This was mentioned in rstudio/bookdown#975
If it supports all language, this is another good point.
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 !
from bookdown-demo.
from bookdown-demo.
@ShKlinkenberg Good to know! I'll make a CRAN release in a couple of weeks. Thanks for confirming!
from bookdown-demo.
You don't need search: yes
because searching is enabled by default.
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.
from bookdown-demo.
Oh, OK, got it. Viewing in external browser--so it won't work locally. Sorry!
from bookdown-demo.
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
from bookdown-demo.
@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
from bookdown-demo.
Hi @yihui, I am also experiencing some problems with the search option. I have a page https://jura.tepedu.dk
When i type f or click the search icon I am not getting the search box anymore it used to work. any ideas :O)
from bookdown-demo.
@cphthomas Please make sure you are using the latest version of bookdown to compile the book.
from bookdown-demo.
Hi @yihui, thanks for your quick reply :O) I'm building the book on rstudio.cloud using:
Package: bookdown
Type: Package
Title: Authoring Books and Technical Documents with R Markdown
Version: 0.9
from bookdown-demo.
@cphthomas 0.9 is not the latest: https://cran.rstudio.com/web/packages/bookdown/
from bookdown-demo.
Hi @yihui, thanks a lot, and thank you for a wonderful package :O)
from bookdown-demo.
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.
from bookdown-demo.
@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.
from bookdown-demo.
Thanks Yihui, all my search bars work locally when I run a server.
from bookdown-demo.
from bookdown-demo.
In both my case and that of @ShKlinkenberg, I think this is caused by an invalid search_index.json
. Plugging https://github.com/ShKlinkenberg/Interactive_Teaching_Techniques/blob/master/docs/search_index.json and https://github.com/ropensci-books/drake/blob/f5c580623cfe8d36478aa41662c25dcc1f63d134/search_index.json into https://jsonlint.com/ expose lints. When I manually switch to a valid search_index.json
in ropensci-books/drake@6654d20, the search bar starts working.
In my case, I think the problem is that search_index.json
cannot handle special characters from crayon
, so I need to set options(crayon.enabled = FALSE)
in all the chapters. In @ShKlinkenberg's case, there is a mysterious special character just before the ## Student Questions
header in interaction-through-homework.html
. In interaction-through-homework.Rmd
, there is a dot before the ##
in the header title (i.e. �## Student Questions
). Removing it and rerunning bookdown::render_book()
fixes the search bar.
So I think somewhere in the stack, the text in search_index.json
should be converted to an encoding that can be parsed.
from bookdown-demo.
Now it should be fixed via
remotes::install_github('rstudio/bookdown')
Thanks!
from bookdown-demo.
does search bar support all languages, i did some test, searching Chinese Characters, doesn't seem to work
from bookdown-demo.
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 Gitbook prebuilds the index data instead: https://github.com/GitbookIO/plugin-search
from bookdown-demo.
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
from bookdown-demo.
Related Issues (20)
- Typo of inventor of bookdown package * Yihui Xie
- I tried to used Korean alphabet but it does not come out right HOT 7
- My bookdown project does not render with portuguese (Brazil) HOT 1
- EPUB output do not have figure and table identifiers while compiling bookdown-demo book HOT 3
- bad restore file magic number HOT 3
- Unable to "Build Book" at very start of book HOT 5
- Environment snugshade undefined. HOT 4
- knitr::include_graphics for pdf_document
- Suggestion: change this to a template repository in settings HOT 4
- chapter references not found in demo HOT 1
- chapter_name: !expr function(i) doesn't work expectly HOT 4
- Error 83: running filter pandoc-citeproc HOT 3
- search tool doesn´t work HOT 11
- Deploy gitbook() and bs4_book() using last dev version
- Build Book returns Error in vapply... HOT 1
- Unable to "Build Book" use the bookdown-demo HOT 4
- object 'is_abs_path' not found HOT 5
- Appendix
- Stroke diagrams overlap vertically HOT 3
- Table of contents stopped working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bookdown-demo.