An open API service indexing awesome lists of open source software.

https://github.com/kaihendry/toc

Creates a Table Of Contents
https://github.com/kaihendry/toc

contents document faq html navigation table toc

Last synced: 9 months ago
JSON representation

Creates a Table Of Contents

Awesome Lists containing this project

README

          

# Creates a table of contents from [h1, h2, h3, h4, h5, and h6 elements](https://html.spec.whatwg.org/multipage/semantics.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements)

[![Build Status](https://travis-ci.org/kaihendry/toc.svg?branch=master)](https://travis-ci.org/kaihendry/toc)

Demo

An element with `data-fill-with="table-of-contents"` is filled with an ordered list of the headers.

This allows users to hyperlink directly to answers.

## Install

To install:

go install github.com/kaihendry/toc/cmd/toc

To keep upto date:

go get -u github.com/kaihendry/toc/cmd/toc

## Example

`foo.html` contains:

FAQ



How do I create a FAQ?

Like this!

Run the tool over the HTML

$ toc foo.html

And something like the following should print to `/dev/stdout`

FAQ





  1. How do I create a FAQ?



How do I create a FAQ?


Like this!

As used on:

*

## Acknowledgements

Many thanks to [tabatkins's bikeshed](https://github.com/tabatkins/bikeshed) for the inspiration & the most helpful [Golang programmer I know, Zoltan](https://github.com/zgiber).