/gentoc

A simple command-line tool written in C for generating a Table of Contents (ToC) for markdown files.

Primary LanguageCMIT LicenseMIT

Gentoc

gentoc is a simple command-line tool written in C for generating a Table of Contents (ToC) for markdown files. It processes the markdown headers in the file and generates corresponding ToC entries.

Features

  • Parses markdown headers.
  • Generates ToC entries in markdown format.
  • Converts headers to lowercase and replaces spaces with hyphens for link compatibility.

Usage

To use gentoc, compile the source code and run the executable with a markdown file as an argument.

Compilation

A Makefile is provided for convenience. Ensure you have make and a C compiler (such as gcc) installed. You can compile the code using:

make

This will create an executable named gentoc on Linux or gentoc.exe on Windows.

Running

Once compiled, you can run gentoc with a markdown file as follows:

./gentoc [file]

For example:

./gentoc example.md

This will output the Table of Contents for example.md.

Example

Given a markdown file example.md with the following content:

# Main Title

## Introduction

## Usage

### Installation

### Running the Application

## Contributing

## License

Running ./gentoc example.md will produce:

- [Introduction](#introduction)
- [Usage](#usage)
  - [Installation](#installation)
  - [Running the Application](#running-the-application)
- [Contributing](#contributing)
- [License](#license)

Contributing

Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.