tocer

A command line interface for generating Markdown table of contents.

https://github.com/bkuhlmann/tocer

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.9%) to scientific vocabulary

Keywords

markdown table-of-contents toc
Last synced: 6 months ago · JSON representation ·

Repository

A command line interface for generating Markdown table of contents.

Basic Info
Statistics
  • Stars: 46
  • Watchers: 5
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Topics
markdown table-of-contents toc
Created over 10 years ago · Last pushed 6 months ago
Metadata Files
Readme Funding License Citation

README.adoc

:toc: macro
:toclevels: 5
:figure-caption!:

= Tocer

Tocer (a.k.a. Table of Contenter) is a command line interface for generating table of contents for
Markdown files. Use this tool to automatically manage and update your documentation with minimal
effort. Works on single files or multiple files within nested directory structures.

toc::[]

== Features

* Supports Markdown ATX-style headers. Example: `# Header`.
** Does not support header suffixes. Example: `# Header #`.
** Does not support header prefixes without spaces. Example: `#Header`.
* Supports table of contents generation for single or multiple files.
* Supports custom label. Default: `## Table of Contents`.
* Supports file list filtering. Default: `"README.md"`.
* Prepends table of contents to Markdown documents that don’t have table of contents.
* Rebuilds Markdown documents that have existing table of contents.

== Requirements

. A UNIX-based system.
. link:https://www.ruby-lang.org[Ruby].

== Setup

To install _with_ security, run:

[source,bash]
----
# 💡 Skip this line if you already have the public certificate installed.
gem cert --add <(curl --compressed --location https://alchemists.io/gems.pem)
gem install tocer --trust-policy HighSecurity
----

To install _without_ security, run:

[source,bash]
----
gem install tocer
----

You can also add the gem directly to your project:

[source,bash]
----
bundle add tocer
----

== Usage

=== Command Line Interface (CLI)

From the command line, run: `tocer --help`

image:https://alchemists.io/images/projects/tocer/screenshots/usage.png[Usage,width=581,height=326,role=focal_point]

To generate the table of contents at a specific position within your Markdown files, add the
following lines to your file(s) prior to generation:

[source,markdown]
----


----

In the case that Tocer has auto-generated a table of contents for a Markdown file; the existing
table of contents has become stale; or placement of the table of contents has changed, you can
re-run Tocer on that file to auto-update it with new table of contents.

=== Customization

This gem can be configured via a global configuration: `~/.config/tocer/configuration.yml`.

It can also be configured via link:https://alchemists.io/projects/xdg[XDG] environment
variables.

The default configuration is as follows:

[source,yaml]
----
label: "## Table of Contents"
patterns:
  - "README.md"
root_dir: "."
----

Feel free to take this default configuration, modify, and save as your own custom
`configuration.yml`.

The `configuration.yml` file can be configured as follows:

* `label`: The header label for the table of contents.
* `patterns`: The list of included files.
* `root_dir`: The root path to use for processing files.

There are multiple ways the include list can be defined. Here are some examples:

[source,yaml]
----
# Use an empty array to ignore all files:
:patterns: []

# Use an array of wildcards for groups of files with similar extensions:
:patterns:
  - "*.md"
  - "*.mkd"
  - "*.markdown"

# Use a mix of wild cards and relative names/paths to customized as necessary:
:patterns:
  - "README.md"
  - "docs/*.md"
  - "*.markdown"

# Use a recursive glob to traverse and update all sub-directories:
:patterns:
  - "**/*.md"
----

=== Rake

You can add Rake support by adding the following to your `Rakefile`:

[source,ruby]
----
begin
  require "tocer/rake/register"
rescue LoadError => error
  puts error.message
end

Tocer::Rake::Register.call
----

Once required and registered, the following tasks will be available (i.e. `bundle exec rake -T`):

....
rake toc[label,includes]   # Insert/Update Table of Contents
....

You can invoke the task as follows (quotes are only necessary if spaces are used):

[source,bash]
----
rake toc["## Example, *.md"]
----

== Development

To contribute, run:

[source,bash]
----
git clone https://github.com/bkuhlmann/tocer
cd tocer
bin/setup
----

You can also use the IRB console for direct access to all objects:

[source,bash]
----
bin/console
----

== Tests

To test, run:

[source,bash]
----
bin/rake
----

== link:https://alchemists.io/policies/license[License]

== link:https://alchemists.io/policies/security[Security]

== link:https://alchemists.io/policies/code_of_conduct[Code of Conduct]

== link:https://alchemists.io/policies/contributions[Contributions]

== link:https://alchemists.io/policies/developer_certificate_of_origin[Developer Certificate of Origin]

== link:https://alchemists.io/projects/tocer/versions[Versions]

== link:https://alchemists.io/community[Community]

== Credits

* Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].
* Engineered by link:https://alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].

Owner

  • Name: Brooke Kuhlmann
  • Login: bkuhlmann
  • Kind: user
  • Location: Boulder, CO USA
  • Company: Alchemists

Quality over quantity.

Citation (CITATION.cff)

cff-version: 1.2.0
message: Please use the following metadata when citing this project in your work.
title: Tocer
abstract: A command line interface for generating Markdown table of contents.
version: 19.3.0
license: Hippocratic-2.1
date-released: 2025-07-19
authors:
  - family-names: Kuhlmann
    given-names: Brooke
    affiliation: Alchemists
    orcid: https://orcid.org/0000-0002-5810-6268
keywords:
 - ruby
 - command line interface
 - markdown
 - documentation
 - table of contents
repository-code: https://github.com/bkuhlmann/tocer
repository-artifact: https://rubygems.org/gems/tocer
url: https://alchemists.io/projects/tocer

GitHub Events

Total
  • Watch event: 2
  • Delete event: 174
  • Push event: 46
  • Create event: 7
Last Year
  • Watch event: 2
  • Delete event: 174
  • Push event: 46
  • Create event: 7

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 808
  • Total Committers: 2
  • Avg Commits per committer: 404.0
  • Development Distribution Score (DDS): 0.001
Past Year
  • Commits: 87
  • Committers: 1
  • Avg Commits per committer: 87.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Brooke Kuhlmann b****e@a****o 807
Olle Jonsson o****n@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 3
  • Total pull requests: 4
  • Average time to close issues: 3 days
  • Average time to close pull requests: 1 day
  • Total issue authors: 3
  • Total pull request authors: 3
  • Average comments per issue: 2.33
  • Average comments per pull request: 2.75
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • paul (1)
  • ghost (1)
  • eebs (1)
Pull Request Authors
  • bkuhlmann (2)
  • MadBomber (1)
  • olleolleolle (1)
Top Labels
Issue Labels
bug (1)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • rubygems 184,551 total
  • Total dependent packages: 10
    (may contain duplicates)
  • Total dependent repositories: 18
    (may contain duplicates)
  • Total versions: 113
  • Total maintainers: 1
proxy.golang.org: github.com/bkuhlmann/tocer
  • Versions: 20
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.5%
Average: 6.7%
Dependent repos count: 6.9%
Last synced: 6 months ago
rubygems.org: tocer

A command line interface for generating Markdown table of contents.

  • Versions: 93
  • Dependent Packages: 10
  • Dependent Repositories: 18
  • Downloads: 184,551 Total
Rankings
Dependent packages count: 1.8%
Dependent repos count: 5.6%
Downloads: 7.0%
Stargazers count: 8.2%
Average: 8.9%
Forks count: 22.1%
Maintainers (1)
Funding
  • https://github.com/sponsors/bkuhlmann
Last synced: 6 months ago

Dependencies

Gemfile rubygems
  • amazing_print ~> 1.4 development
  • caliber ~> 0.11 development
  • debug ~> 1.6 development
  • git-lint ~> 4.0 development
  • guard-rspec ~> 4.7 development
  • rake ~> 13.0 development
  • reek ~> 6.1 development
  • rspec ~> 3.11 development
  • simplecov ~> 0.21 development
tocer.gemspec rubygems
  • auto_injector ~> 0.7
  • cogger ~> 0.2
  • dry-container ~> 0.10
  • refinements ~> 9.6
  • runcom ~> 8.5
  • spek ~> 0.5
  • zeitwerk ~> 2.6