Xaringan: Add a "search content" feature in HTML

Created on 22 Jan 2021  路  9Comments  路  Source: yihui/xaringan

For slides that are let available after a talk, or for slides shared during tutorials, that would be great if attendees could be able to search the content.
There exists this feature that has not been updated for a while for {remark.js}, this can be a good start: https://github.com/arestivo/remark.search

enhancement

Most helpful comment

@statnmap @cderv I added search to xaringanExtra this weekend. Please give it a try and let me know what you think!

All 9 comments

Wow the linked example is so good. Would "grab remark.search and plug it into xaringan" an option?

Maybe. I tried with a personal modified version of {xaringan} but could not make it work properly.
I did not get enough time to explore the reasons though. In my case, the search bar starts and can be used, but some characters can not be searched. I assume there is a JS conflict but I cannot figure it out.

Add call to these files in the header:

c('mark.js', 'remark.search.js')

Add script in the footer with this function:

searchbar <- function() {
tmp_js <- tempfile('searchbar', fileext = '.js')

cat('
<script>',
"
window.addEventListener('load', function() {
    RemarkSearch.create();
});
</script>", file = tmp_js)
return(tmp_js)
}

I'd be happy to take on this feature request in xaringanExtra, where I think it would fit in nicely. That said, @yihui if you want to add this as a core xaringan feature I'd be equally happy 馃槃

Hey @gadenbuie,

IMO xaringanExtra seems a nice place to have this if you think it could leave outside from xaringan internals.

As extra feature to activate with other extra features!

@statnmap @cderv I added search to xaringanExtra this weekend. Please give it a try and let me know what you think!

So efficient ! Nice demo and this works really well ! It is easy to setup and customize.
xaringanExtra seems a great place for it! @statnmap what do you think ?

This works perfectly ! Thank you so much !

It does work play nice along with tileview mode though, as when you press "o" in the search bar, it switches to the overview mode. But alone, it works exactly as expected.

That is cool ! I think xaringanExtra is a great place for this!
Thanks @gadenbuie ! I'll close this Feature Request here then.

@gadenbuie Please feel free to implement this type of feature in xaringanExtra. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paullemmens picture paullemmens  路  5Comments

royfrancis picture royfrancis  路  4Comments

kevinykuo picture kevinykuo  路  3Comments

tcgriffith picture tcgriffith  路  4Comments

grawil picture grawil  路  4Comments