package mdx
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=603990812efa7184d88a4896d7f9369b43d32e3dbdd26fe9cecb5a5f5f32c1e0
sha512=461bb3f2e25f8a2f869577ec8f95f731e0765a534043088fdc88ee9fabaa52926eb957124529ff889f1d698df594b235219c677521eebe01a5959c7db75131ea
doc/mdx/Mdx/index.html
Module MdxSource
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.
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.
Document
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.
parse_lexbuf l is of_string of l's contents.
Evaluation
val run_to_stdout :
?syntax:syntax ->
f:(string -> t -> string) ->
string ->
(unit, [ `Msg of string ]) Result.resultrun_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.
val run_to_file :
?syntax:syntax ->
f:(string -> t -> string) ->
outfile:string ->
string ->
(unit, [ `Msg of string ]) Result.resultSame as run_to_stdout but writes the corrected version to outfile
val run :
?syntax:syntax ->
?force_output:bool ->
f:(string -> t -> string) ->
string ->
(unit, [ `Msg of string ]) Result.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.