caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: [Caml-list] [batteries] ... how to create (format) directives that do not take any arguments?
Date: Mon, 25 Nov 2013 15:46:08 +0000	[thread overview]
Message-ID: <529370C0.9020801@gmail.com> (raw)

Dear all,

I would like to define custom directives, that would enable me to write code like e.g. this:

Print.printf "regular %bold_on bold %bold_off regular %italic_on italic %italic_off";

This might expand to (in HTML codes)

              regular <B>bold</B> regular <I>italic</I>

or in ANSI codes to something analogous.

I am currently looking at:

  http://ocaml-batteries-team.github.io/batteries-included/hdoc/BatPrint.html

It refers to:

  https://github.com/ocaml-batteries-team/batteries-included/blob/master/examples/snippets/test_printf.ml

Those things work, although there is no example for:

  Print.literal

which might be (?) what I need to employ.

Can somebody give me some advice how to create simple "parameterless format directives" (like those above)?

----

Basically, I just want to refactor some weird markup out of the literal string while I do not want to reinsert the refactored stuff via %s because it is not maintainable.

             reply	other threads:[~2013-11-25 15:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 15:46 Matej Kosik [this message]
2013-11-25 16:27 ` Gabriel Scherer
2013-11-27 11:37   ` Matej Kosik
2013-11-28  6:30     ` [Caml-list] [batteries] ... how to create (format) directives oleg
2013-11-29  9:32       ` Matej Kosik
2013-11-30  3:15         ` oleg
2013-11-27 11:54 ` [Caml-list] [batteries] ... how to create (format) directives that do not take any arguments? Jeremie Dimino
2013-11-27 12:52   ` Matej Kosik
2013-11-27 13:00     ` Jeremie Dimino
2013-11-29  9:32       ` Matej Kosik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=529370C0.9020801@gmail.com \
    --to=5764c029b688c1c0d24a2e97cd764f@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).