Extract of a bookdown with full table of contents

Hi all,

I currently have a full ebook (=ebook) written in bookdown with a large table of content.
I am about to restrict the access to this ebook after registration on a website.
I would like to have an extract of this ebook (= extract book) accessible before registration though.

In this extract book, I would like to restrict the access to some chapters while keeping the entire TOC of the ebook on the left side.

In TOC, the reader would see something like:

  1. Chapter 5
    5.1 Section 5.1
    5.2 Section 5.2
    5.3 Section 5.3

Once the reader click on '5.2 Section 5.2' in the TOC, I would like him to see:

  1. Chapter 5
    "This chapter is only accessible after FREE registration".

I have searched a lot to make the title of specific sections invisible somehow (like setting the colour to white) but with no success. Anyone has a work around to suggest?

Thanks,

Maxime

This is tricky but you can probably achieve this three ways:

  • Use knitr chunk as a way to do conditional insertion of child document with your content. For the free version, you would not insert the real child document, but the dummy one. You could then build a version of the ebook with a variable as parameters so that it will insert the right child. Example of this conditional insertion at 16.4 Child documents (*) | R Markdown Cookbook

    This is to me the easiest way you can achieve that with bookdown

  • A post processing of the produced HTML in the ebook. Can be tricky to not break the ebook format.

  • A Lua filter for Pandoc so that you can replace all sections by some specific content. It could be tricky to build as you need to understand Pandoc's AST and how to write a filter using Lua. But it would definitely work as this will allow to identify some Nodes in the tree (your whole chapters to hide) and only keep the header, while replace content.

Hope it helps

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.