Introducing modoc, a Lightweight Framework for Large Markdown Documents
I thoroughly enjoy writing and generally when I write, I do so using Markdown for formatting. Markdown is great because it can be easily exported to HTML, a PDF, Word Documents, etc. Thereβs great tooling around Markdown, abd itβs a well supported markup language.
My only problem is when Iβm writing larger documents, such as if you were to write book, you quickly end up with a massive, unwieldly document. A few problems that come to mind:
- If you want to go back and reorganize sections or chapters of your document itβs usually pretty difficult as you have to recreate your headings as the heading levels wonβt match up.
- How do you go about managing a table of contents? You could manually manage it, but updating the links and text, and maintaining order and depth of each heading is a pain.
What I wanted was a small, lightweight framework that can be used to organize a larger document into smaller, more manageable chunks, but still output to a single Markdown file complete with table of contents. Thatβs where modoc comes in.
With modoc
you simply create a directory structure where each directory has a TITLE and README.md file, and modoc
does all the rest. Hereβs what the directory structure for the README document of the opensource modoc repository looks like:
$ tree examples/readme/
examples/readme/
βββ 1-features
βΒ Β βββ README.md
βΒ Β βββ TITLE
βββ 2-usage
βΒ Β βββ 1-install
βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βββ TITLE
βΒ Β βββ 2-command-line
βΒ Β βΒ Β βββ 1-init
βΒ Β βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βΒ Β βββ TITLE
βΒ Β βΒ Β βββ 2-compile
βΒ Β βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βΒ Β βββ TITLE
βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βββ TITLE
βΒ Β βββ 3-project-structure
βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βββ TITLE
βΒ Β βββ 4-examples
βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βββ TITLE
βΒ Β βββ TITLE
βββ 3-authors
βΒ Β βββ 1-contributing
βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βββ TITLE
βΒ Β βββ README.md
βΒ Β βββ TITLE
βββ 4-license
βΒ Β βββ README.md
βΒ Β βββ TITLE
βββ README.md
βββ TITLE
11 directories, 23 files
Directories are loaded into modoc
recursively and in alphabetical order, and the titles, sections, and table of contents are created from there. In the example above, you end up with a document that looks like so:
# Features
...
# Usage
...
## Install
...
## Command-Line
...
### init
...
### compile
...
(Take a look at the full document at github.com/KyleBanks/modoc.)
modoc
also generates the table of contents at the top of the document, complete with links to each section, so you donβt have to worry about it:
## Table of Contents
- [Features](#features)
- [Usage](#usage)
- [Install](#install)
- [Command Line](#command-line)
- [init](#init)
- [compile](#compile)
- [Project Structure](#project-structure)
- [Examples](#examples)
- [Authors](#authors)
- [Contributing](#contributing)
- [License](#license)
This makes it really easy to structure and organize larger writing projects without having a full-blown framework to get in your way. Check it out on GitHub at github.com/KyleBanks/modoc and try it for yourself. If you have any ideas or run into trouble, donβt hesitate to create an issue!