Make your long documents easy to read by adding a table of contents on the side. A lo-fi Gitbook alternative, using Pandoc and bash.
To use, just create three files, run ./tocdoc.sh
, and open up generated/index.html
to see your TOCdoc.
Check out the live example based on the default example document in document/
.
TOCdoc is based on tools like:
- Gitbook (a fremium service)
- HonKit (a fork of the old gitbook-cli)
- mdBook (runs on Rust)
- Bookdown (R Markdown)
- docsify (client-side markdown rendering)
TOCdoc does less. But it also requires less configuration.
First, install Pandoc.
Then, git clone https://github.com/nickloewen/tocdoc
.
Or, if you want to clone into a folder with a better name:
$ mkdir philosophiae-naturalis-principia-mathematica
$ cd philosophiae-naturalis-principia-mathematica
$ git clone https://github.com/nickloewen/tocdoc .
- Create your document, and save it to
document/body.md
. - Create your table of contents and save it to
document/contents.md
. - In
documents/title.txt
, write the title you want displayed on the browser tab. - Run
./tocdoc.sh
. - Check out the output at
generated/index.html
.
- Use Pandoc markdown
- I recommend using an H1 for the overall page title, and H2s for chapter titles. A horizontal rule (markdown:
***
) between chapters is nice, too. - Add anchor links to your headings like this:
## Chapter 2 {#ch-2}
. - The current stylesheet assumes that your first H1 will be followed by a byline, a horizontal rule, and the first chapter, with no additional content.
- You can use an H2 to add a title to your table of contents. (Other markdown will also work, it's just not covered by the stylesheet.).
- Create your table of contents using a regular markdown list (bulleted lists, numbered lists, and automatically numbered lists wll all work).
- Link to your headings like this:
[Chapter 2](#ch-2)
If you want to add other static assets (like images), you can put those straight into generated/
.