markdown_monolith

Documentation OCaml License

An OCaml library and CLI tool to produce a single monolithic Markdown file by parsing with Cmarkit, detecting navigational TOC-like link lists, and recursively inlining referenced files.

📚 View Full API Documentation

Installation

opam install markdown_monolith

Documentation

Full API documentation is available at: https://durbatuluk1701.github.io/markdown_monolith/

The documentation includes:

You can also build the documentation locally:

dune build @doc
# View at _build/default/_doc/_html/markdown_monolith/index.html

Usage

Basic Usage

markdown_monolith input.md -o output.md

Examples

Basic inlining:

markdown_monolith main.md -o monolith.md

Enable remote fetching (use with caution):

markdown_monolith main.md --allow-remote -o output.md

Control recursion depth:

markdown_monolith main.md --max-depth 5 -o output.md

Library API

For detailed API documentation, see https://durbatuluk1701.github.io/markdown_monolith/

open Markdown_monolith

(* Create custom configuration *)
let config = {
  Monolith.default_config with
  allow_remote = false;  (* Keep remote fetching disabled for security *)
  max_depth = 5;         (* Limit recursion depth *)
  dedupe = true;         (* Prevent duplicate inlining *)
}

(* Process a file *)
match Monolith.monolith_of_file ~config "input.md" with
| Ok doc -> 
    let output = Cmarkit_commonmark.of_doc doc in
    print_endline output
| Error msg -> 
    prerr_endline ("Error: " ^ msg)

Key Functions

See the full API documentation for complete details.

Dependencies

License

See LICENSE file.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

For bug reports and feature requests, please use the GitHub issue tracker.