package markdown_monolith
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=780e6bb03f474a071eff8099862aaff5
sha512=d108fab9854ef32d23de532d66046511c202a1667106b20eb9339f82dec416c02f95589dc7183d5fcd44864cd53fd76c8a478639106e2e7e6523d2c526c7fbdb
Description
OCaml library and CLI to produce a single monolithic Markdown file by parsing with Cmarkit, detecting link lists, and recursively inlining referenced files. Supports local and remote (HTTP/HTTPS) sources with configurable depth limits and deduplication.
README
markdown_monolith
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.
Installation
opam install markdown_monolithDocumentation
Full API documentation is available at: https://durbatuluk1701.github.io/markdown_monolith/
The documentation includes:
- Comprehensive API reference for all modules and functions
- Detailed configuration options with examples
- Usage patterns and best practices
- Limitations and security considerations
You can also build the documentation locally:
dune build @doc
# View at _build/default/_doc/_html/markdown_monolith/index.htmlUsage
Basic Usage
markdown_monolith input.md -o output.mdExamples
Basic inlining:
markdown_monolith main.md -o monolith.mdEnable remote fetching (use with caution):
markdown_monolith main.md --allow-remote -o output.mdControl recursion depth:
markdown_monolith main.md --max-depth 5 -o output.mdLibrary 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
monolith_of_file: Main function to process a markdown file into a monolithic document
See the full API documentation for complete details.
Dependencies
cmarkit: Modern CommonMark parser and renderercmdliner: CLI argument parsinglwt: Asynchronous I/Ocohttp-lwt-unix(>= 5.0): HTTP client for remote fetchinglwt_ssl(>= 1.2.0): SSL/TLS support for HTTPS
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.