MdxMdx 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 Lexer_mdx : sig ... endmodule Output : sig ... endTest outputs.
module Cram : sig ... endCram tests
module Deprecated : sig ... endmodule Document : sig ... endmodule Toplevel : sig ... endToplevel phrases.
module Library : sig ... endmodule Ocaml_delimiter : sig ... endmodule Part : sig ... endmodule Block : sig ... endCode blocks headers.
module Migrate_ast : sig ... endmodule Mli_parser : sig ... endmodule Compat : sig ... endmodule Util : sig ... endmodule Prelude : sig ... endmodule Syntax : sig ... endmodule Label : sig ... endmodule Dep : sig ... endmodule Ocaml_env : sig ... endBlock environments.
include module type of DocumentThe type for the lines of a markdown or cram file.
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.
val envs : t -> Ocaml_env.Set.tval of_string : syntax -> string -> (t, [ `Msg of string ]) Result.resultof_string syntax s is the document t such that to_string ~syntax t = s.
val parse_file : syntax -> string -> (t, [ `Msg of string ]) Result.resultparse_file s is of_string of s's contents.
val parse_lexbuf :
string ->
syntax ->
Lexing.lexbuf ->
(t, [ `Msg of string ]) Result.resultparse_lexbuf l is of_string of l's contents.
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.
val section_of_line : line -> (int * string) optionsection_of_line l is l's section.