Pangamebook is a free filter I wrote for the (also free) Pandoc document conversion tool. It shuffles and numbers sections to create (static) gamebooks. So this is for choice-based IF that can be represented on paper, or in a EPUB, but not for those fancy scripted books where the computer keeps track of stuff for you. It also comes with a second script called pangamebookdot that generates a DOT file for Graphviz, so you can visualize how all the sections in the gamebook are connected. All is explained in the README, at least in theory.
If this sounds vaguely familiar it is probably because of the (equally cleverly named) gamebookformat tool that I posted about here a few years ago. That one was much more complex as it had its own configurable template system for various output formats. Pangamebook building on top of Pandoc is a much more sane approach to do the same thing. There are a few advanced features of gamebookformat that are not in pangamebook (yet?) but I think the only must-haves to layout a gamebook are included and other than bugfixes I have no further plans for it.