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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 4604E7EE35 for ; Wed, 23 Mar 2016 16:01:52 +0100 (CET) IronPort-PHdr: 9a23:6BJDlRKJBY9SWjzLPdmcpTZWNBhigK39O0sv0rFitYgULf/xwZ3uMQTl6Ol3ixeRBMOAu6IC0rSd7PiocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC34Luiavto9X6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD86Fpy8kVWKHzeeIjRrxdDSg6G3gy4Nz3uBLDSwqW+3ZaVX8Z1lJDCg3BqRX7RYvZsy3gt+M71jPJE9fxSOUeVDKl7rsjdhb1hyABf2oz/WfQi9A2kqtGrxWnjxN6yo/QJoqSMawtLevmYdoGSD8ZDY5qXCtbD9bkYg== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=benoit.vaugon@gmail.com; spf=Pass smtp.mailfrom=benoit.vaugon@gmail.com; spf=None smtp.helo=postmaster@mail-wm0-f43.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of benoit.vaugon@gmail.com) identity=pra; client-ip=74.125.82.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="benoit.vaugon@gmail.com"; x-sender="benoit.vaugon@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of benoit.vaugon@gmail.com designates 74.125.82.43 as permitted sender) identity=mailfrom; client-ip=74.125.82.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="benoit.vaugon@gmail.com"; x-sender="benoit.vaugon@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wm0-f43.google.com) identity=helo; client-ip=74.125.82.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="benoit.vaugon@gmail.com"; x-sender="postmaster@mail-wm0-f43.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DGAQCTrvJWkitSfUpehAZ6qEqHJoxyGYV0AoE8PBABAQEBAQEBARABAQEBBwsLCSEvgi2CFQEBBBIRBAsBBQgBGxwCAwwGBQsPAgUWCwICCQMCAQIBEREBBQEcBwwIAQEeh28BAxKiKYExPjGLNoFqgleGeAoZJw1RhCABAQEBAQUBAQEBAQEBEwEFCgVthSKERIQ6gwKCVgWXWoFShB+IE4FmTYZ1DiOFMY1JL4EPN4IhHoFSaYoLAQEB X-IPAS-Result: A0DGAQCTrvJWkitSfUpehAZ6qEqHJoxyGYV0AoE8PBABAQEBAQEBARABAQEBBwsLCSEvgi2CFQEBBBIRBAsBBQgBGxwCAwwGBQsPAgUWCwICCQMCAQIBEREBBQEcBwwIAQEeh28BAxKiKYExPjGLNoFqgleGeAoZJw1RhCABAQEBAQUBAQEBAQEBEwEFCgVthSKERIQ6gwKCVgWXWoFShB+IE4FmTYZ1DiOFMY1JL4EPN4IhHoFSaYoLAQEB X-IronPort-AV: E=Sophos;i="5.24,382,1454972400"; d="scan'208";a="170414345" Received: from mail-wm0-f43.google.com ([74.125.82.43]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 23 Mar 2016 16:01:51 +0100 Received: by mail-wm0-f43.google.com with SMTP id l68so200039047wml.0 for ; Wed, 23 Mar 2016 08:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=Zd/oGzzupnSGQ2T0zAT3akstn/tmXVGOGVI4vgBNC4s=; b=R7iyGUzSSzD/6sea3hnZwWoNuPh9SS0XqrqBHUiSbR1ndzqAmDIXJp6HHXDEUtuca9 pTsQHKy/bkHr7CKL5Vs2oJs/Lnij3wOAU+q81hphiuAXyyL32nzL9/Jw5Ih9e93lbq1d XuuK06rwTtQn1CefX5DeftgVFQLdDwoBxJIbKWjzL3IPhaxSBm/g8gLdv8gPMuflWWTN UZkJQ/vOxMausB2N01pQDLOMyu3bI0zf+m/BxghFsiMmqyhjsm/c8Vdjv1iXjU5JOG8z e2jNaUeXC4p3e4zE1AUc9ArnHXBsj5Nhtoe+h/i+lStuUgdpf8tAbz6mwhO1UaAX0ZAW 2Kaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=Zd/oGzzupnSGQ2T0zAT3akstn/tmXVGOGVI4vgBNC4s=; b=FkDS5JeSwrxD4SP86i8PZ31lGCIDxfum7aGvsUACH0wlrpR2weoepvfOJrRfC5chwd hGwGzIzKLiYU+WM5bL/0hC7FBY93EKWfMtFOta87/5hOK/+8Y/Sn8A5sG1F1B2p2f+BF 6PdiSsEecdo10dOaXyzrNRnIXrD0lw36lCANEqWYGDEFIN7EjOA1+euqA/FHfINGh52+ OBmhOxFQyvXPxtzOd3PiPVYNbjA/U62V6Z54UTDjW3/t9uum6XYsh8AW7biczpEWzYPb hPcb3B3TL9+NS4FMeEtjgZcPGREg/K9G6CI7V0ONBphBFIwe80NknFDOcKsfFtwhehXZ dVvA== X-Gm-Message-State: AD7BkJJfcsYow5Lo2XjzrnK3gOs/XpyBwkrWziIwgf6xPU4YrCFIJ0HzP7zsfndRxKDp9w== X-Received: by 10.194.75.196 with SMTP id e4mr3852146wjw.134.1458745311010; Wed, 23 Mar 2016 08:01:51 -0700 (PDT) Received: from [192.168.1.110] ([134.157.22.155]) by smtp.googlemail.com with ESMTPSA id y72sm3378072wmh.21.2016.03.23.08.01.50 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 23 Mar 2016 08:01:50 -0700 (PDT) To: alan.schmitt@polytechnique.org, caml-list@inria.fr References: From: Benoit Vaugon Message-ID: <56F2AFDD.3090609@gmail.com> Date: Wed, 23 Mar 2016 16:01:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] A question about Format and semantic tags Hello Alan, In fact, the Format tag activation is local to a formatter. The function Format.set_tags enables tags only for the std_formatter (associated to stdout). If you want to activate tags for the Format.str_formatter, you should call: Format.pp_set_tags Format.str_formatter true; instead of: Format.set_tags true; Format.set_mark_tags true; Benoît. Le 23/03/2016 13:47, Alan Schmitt a écrit : > 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 = > try > let handle = 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 = "test_out.txt" > > let out = "@[Hello World@ Hello@ Hello again@ Hello@ Hello again@ Hello@ Hello again@ @{Hello@ Cut again@}@]" > > let _ = > 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 >