MdxSourceMdx 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.
Stable printing functions built on top of compiler-libs types Use this for user facing part of the code so that mdx's output does not depend on the ocaml version it was built with.
of_string syntax s is the document t such that to_string ~syntax t = s.
parse_file s is of_string of s's contents.
val run_to_stdout :
?syntax:Syntax.t ->
f:(string -> t -> string) ->
string ->
(unit, [ `Msg of string ] list) resultrun_to_stdout ?syntax ~f file runs the callback f on the raw and structured content of file, as specified by syntax (defaults to Markdown). The returned corrected version is then written to stdout.
val run_to_file :
?syntax:Syntax.t ->
f:(string -> t -> string) ->
outfile:string ->
string ->
(unit, [ `Msg of string ] list) resultSame as run_to_stdout but writes the corrected version to outfile
val run :
?syntax:Syntax.t ->
?force_output:bool ->
f:(string -> t -> string) ->
string ->
(unit, [ `Msg of string ] list) resultrun_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.