🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

dmp-table-of-contents

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dmp-table-of-contents

Documark plugin for generating a table of contents.

latest
Source
npmnpm
Version
0.4.1
Version published
Maintainers
1
Created
Source

Documark Table of Contents

npm version dependency status

Documark plugin for generating a table of contents.

This plugin uses wkhtmltopdf its --dump-outline flag to generate the chapter index, which means that the table of contents is always one compilation behind. Compiling twice will ensure you have the latest table of contents.

Usage

  • Install plugin with npm install dmp-table-of-contents --save.

  • Load plugin in document configuration:

    plugins:
      - dmp-table-of-contents
    
  • Add the table of contents in document.jade:

    chapter.no-index
    	h1 Index
    	table-of-contents(depth=2)
    

    The index element (ul) will be automatically appended to the table-of-contents element.

    Tip: Use the chapter numbering plugin for automatic chapter numbering.

  • Additionally add a .no-index class to headers (or one of their parent elements) to skip the index:

    chapter
    	h1.no-index This will not appear in the TOC!
    
    //- Or:
    chapter.no-index
    	h1 One
    	h2 Two
    	h3 Three
    

Configuration

The index depth (default: 3) can be configured with a depth attribute:

table-of-contents(depth=2)

Use startPageCountOn in your document configuration to shift the displayed page numbers:

startPageCountOn: 2   # to make 1 =>  2, 5 => 6, 6 => 7, etc.
startPageCountOn: -3  # to make 1 => -3, 5 => 1, 6 => 2, etc.

Output

The final structure will look like this:

chapter.no-index
	h1 Index
	table-of-contents(depth=2)
		ul.index-1
			li.page-1
				a.chapter-link(href='#chapter-1-subject-x')
					span.chapter-title 1. Subject X
					span.page-number 1
			li.page-2
				a.chapter-link(href='#chapter-2-subject-y')
					span.chapter-title 2. Subject Y
					span.page-number 2
				ul.index-2
					li.page-2
						a.chapter-link(href='#chapter-2-1-subject-z')
							span.chapter-title 2.1. Subject Z
							span.page-number 2

Note: Chapter anchors are the slugified title, prepended with chapter- and appended with -2, -3, etc. (if necessary).

Keywords

documark

FAQs

Package last updated on 20 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts