package mdx
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=b68fea7235aa95a407bccea76352a8a32dee0441a72f701f3aa19d4f1cbd853c
sha512=2853e68f2e91ea36f3f22459ff1cd512237e6380163434e2bd59eee1946d166119663aaafb5acd672cbf285d9f191aee2e39fa5f587cbd41020eeae8815887cf
doc/mdx/Mdx/index.html
Module Mdx
Mdx is a library to manipulate markdown code blocks.
mdx allows to execute code blocks inside markdown files. The supported code blocks are either cram-like tests, raw OCaml fragments or toplevel phrases.
Cram tests and toplevel phrases are sequences of commands and outputs.
module Output : sig ... endTest outputs.
module Cram : sig ... endCram tests
module Toplevel : sig ... endToplevel phrases.
module Block : sig ... endCode blocks.
module Migrate_ast : sig ... endmodule Compat : sig ... endLines
The type for the lines of a markdown or cram file.
Document
type t = line listThe type for mdx documents.
pp is the pretty printer for mdx documents. Should be idempotent with of_string.
val to_string : t -> stringto_string t converts the document t to a string.
of_string syntax s is the document t such that to_string ~syntax t = s.
val parse_lexbuf : syntax -> Lexing.lexbuf -> tparse_lexbuf l is of_string of l's contents.
Evaluation
run_to_stdout ?syntax ~f file runs the callback f on the raw and structured content of file, as specified by syntax (defaults to Normal). The returned corrected version is then written to stdout.
Same as run_to_stdout but writes the corrected version to outfile
run_to_file ?syntax ?force_output ~f ~outfile file runs the callback f similarly to run_to_stdout to generate its corrected version. If force_output is true (defaults to false) or if the corrected version differs from the original file content, it writes it to <file>.corrected. Otherwise, if <file>.corrected already exists, it removes it.
Filtering
val section_of_line : line -> (int * string) optionsection_of_line l is l's section.