OCaml Labs is developing MPP (Meta Preprocessor) [1]. It will be used in a new implementation of ocaml.org [2], which includes pages like 99 problems [3] that are generated by running ocaml code through the toploop. In case blah = Markdown, please also note the new Markdown library [4].

[1] https://github.com/pw374/MPP-language-blender
[2] http://lists.ocaml.org/pipermail/infrastructure/2013-July/000211.html
[3] http://ocaml.org/tutorials/99problems.html
[4] http://lists.ocaml.org/pipermail/infrastructure/2013-July/000223.html



On Mon, Sep 2, 2013 at 11:39 AM, Jonathan Protzenko <jonathan.protzenko@gmail.com> wrote:
Hi,

I am currently writing a big, mostly textual document in format blah
(blah being of a course a meta-variable). Are there any tools that
would allow me to interleave OCaml code with the contents of my
document?

More on my use-case. Creating this document requires me to perform
various subtasks, such as:
- write a code snippet in the document,
- put the code snippet in a file,
- call an external program on the file,
- paste the output into the document.

Naturally, I wish to automate this. I could roll my own set of
commands, and parse them with OCaml, but I would be re-creating a
scripting language, and it seems to me that interleaving OCaml code
within my document would be better. Here's what I have in mind:


blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah
blah ... we thus write the following code ... :

{%
  let code = "<sample code>" in
  output code
%}

blah blah blah ... after running the command blah ... the output is as
follows ... blah

{%
  let f = write_into_temp_file code in
  let s = run_and_read "myprogram" [f] in
  output s
%}

blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah ...


Are you aware of any tool that would allow me to achieve this?

Thanks,

~ jonathan

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs