From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 3E6067EE35 for ; Wed, 23 Mar 2016 13:47:30 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.24,382,1454972400"; d="asc'?scan'208";a="209703474" Received: from charm-ecran.irisa.fr ([131.254.101.83]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 23 Mar 2016 13:47:30 +0100 From: Alan Schmitt To: OCaml Mailing List Date: Wed, 23 Mar 2016 13:47:07 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Subject: [Caml-list] A question about Format and semantic tags --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, I need to output two versions of a string that only differ by the presence of some markers in them, and I want the output to be pretty (it's code to be read). It seems that semantic tags from the Format module would allow me to do this, with identical line breaking as these tags are considered 0 width. Unfortunately I cannot seem to make it work. Here is what I have tried: #+begin_src ocaml let file_put_contents filename text =3D try let handle =3D open_out filename in output_string handle text; close_out handle with Sys_error s -> failwith ("Could not write in file: " ^ filename ^ "\n" ^ s) let filename =3D "test_out.txt" let out =3D "@[Hello World@ Hello@ Hello again@ Hello@ Hello again@ = Hello@ Hello again@ @{Hello@ Cut again@}@]" let _ =3D Format.set_tags true; Format.set_mark_tags true; Format.fprintf Format.str_formatter (Scanf.format_from_string out ""); file_put_contents filename (Format.flush_str_formatter ()) #+end_src To run this I do ~ocamlc -o tags tags.ml && ./tags && cat test_out.txt~. As I have turned on treatment of tags and tag marking, I would expect to see the tag marker in the output string using the default format ( and ), but I do not see them. Am I on the right track by using tags? Could someone point me to my mistake? Thanks a lot, Alan --=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 Monthly Athmospheric CO=E2=82=82 (2016-02, Mauna Loa Obs.): 404.02 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBCgAGBQJW8pBLAAoJEAQNCjtO0uXHdasIALP0AjegiktobO/sPDU5+E29 ZA/oM5f7ccTV1jeHLmhu2cpDFs968Shul3V3R7PmwyuNnwLId4BWYDNnGpewcPCH zFDCmVVnFAhSG+L9lCqqOub+irrDXktKqzAqOTxRKx8j9ebEFgWmO1G5ylIi/GCp I4IbY3Z4DKxS+sYtHZt6ZtduBS1B9tbQ2Oqd1CpWdyB2ukSyAI2mAVhMJiIxTni/ 95smUNkfpiiH4Nhit15QCgdjnV3g+TcnAzuMT+CNKmK9t1lxfyfKjfOkzuyq/nm1 69kEFOhzuVotiRDXT10BLUCjA0+s3/c+HsDsLcxi5vOJYBWp7e6ZCdZ+DEPOWYQ= =4P0D -----END PGP SIGNATURE----- --=-=-=--