From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106665 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: Re: How do I handle strings with " characters in it in METAPOST? Date: Sun, 29 Mar 2020 15:06:24 +0200 Message-ID: <36E421F8-0294-4D04-8C45-0718B47E1727@rna.nl> References: <2CE77B0F-FC9E-4EDB-8A40-F4C5DC3A99B8@rna.nl> <6cd1c797-83de-f317-f46d-1a9ed9cd10a8@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="===============6215093678753240181==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="89941"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mailing list for ConTeXt users To: Wolfgang Schuster Original-X-From: ntg-context-bounces@ntg.nl Sun Mar 29 15:11:10 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jIXiX-000NIB-Kp for gctc-ntg-context-518@m.gmane-mx.org; Sun, 29 Mar 2020 15:11:09 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 97310182E6D; Sun, 29 Mar 2020 15:06:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fHYINX-u0BLu; Sun, 29 Mar 2020 15:06:27 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 746C4182E54; Sun, 29 Mar 2020 15:06:27 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B81E7182E5A for ; Sun, 29 Mar 2020 15:06:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NrEOf42kWb16 for ; Sun, 29 Mar 2020 15:06:25 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=213.125.118.53; helo=mail.rna.nl; envelope-from=gerben.wierda@rna.nl; receiver= Original-Received: from mail.rna.nl (mail.rna.nl [213.125.118.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 29E9A182E4D for ; Sun, 29 Mar 2020 15:06:25 +0200 (CEST) Original-Received: from hermione.rna.nl (hermione.rna.nl [192.168.2.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.rna.nl (Postfix) with ESMTPSA id D0C4536626AA; Sun, 29 Mar 2020 15:06:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1585487184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OEM1jqlGyf8XNOwDD3m1osGywHyX1wMZzQRIvlhXGnM=; b=TKcxNO2lJCcLXdD3cUN7DptiBhpcnPkaVY1mOiz3TXohYnL/lD6LvOv+kUTcyRgDPPf5Kc 6eG8upLEKCe7u6DgkdoSjtSUPuSI4B5RzRziYXrj7HIwTqqAWXLs1TL6QxfbQTVbNJrb/T JkewPpp69QZkE4Ub9kJyZceQVANfBRQEJdMMQVN4/EWRuuN1Ft47wcOTs5JavICmwJNknZ 2rs/nUfMnr9G8C/JHohjK5OYLJfm3zIWbE7h1Yi4FWsL4oxxdj1TNd1pg2/RrD6KQ6yoj8 nqAxnI2a2trp0Q0f09suhvyzqHBgaSA7uRrE/WUOLCoi2ZjsNiW+X1HjPSugCQ== In-Reply-To: <6cd1c797-83de-f317-f46d-1a9ed9cd10a8@gmail.com> X-Mailer: Apple Mail (2.3445.104.14) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:106665 Archived-At: --===============6215093678753240181== Content-Type: multipart/alternative; boundary="Apple-Mail=_40C50356-2085-407C-9C98-9604EEF67FF5" --Apple-Mail=_40C50356-2085-407C-9C98-9604EEF67FF5 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 29 Mar 2020, at 14:35, Wolfgang Schuster = wrote: >=20 > Gerben Wierda schrieb am 29.03.2020 um 14:30: >>> On 29 Mar 2020, at 12:58, Wolfgang Schuster = wrote: >>>=20 >>> Gerben Wierda schrieb am 29.03.2020 um 12:52: >>>> I am using MetaFun (Lua code) to create METAPOST commands from an = XML file. One of the issues I am running into that in METAPOST I have to = handle strings with " characters in them and METAPOST doesn=E2=80=99t = like those. The argument using the string >>>> Foo "Bar=E2=80=9D Foo >>>=20 >>> ^^^ >>>=20 >>> Use correct left quotation marks or \quotation{=E2=80=A6}. >> I=E2=80=99m not hard coding the string, I=E2=80=99m reading it from = an XML. So, whatever I do, I need to do it by manipulating the string. >> E.g. if the string I read contains >> Foo "Bar=E2=80=9D Foo >> your suggestion means I have to programmatically change that to >> Foo \quotation{Bar} Foo >> which is too complicated, given that I don=E2=80=99t have regular = expression replace at my disposal. >> I might be able to change al =E2=80=9C instances into something else = by walking through the string and building a new one. >=20 > Your example uses " before Bar and not =E2=80=9C which is the problem. Yes, I am aware that that is my problem. It is just that I do not have = the luxury to decide myself what will be put in the string. It must work = for any string. So, I will have to be putting that string to \type and = make sure that is used as the label. G --Apple-Mail=_40C50356-2085-407C-9C98-9604EEF67FF5 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On 29 Mar 2020, at 14:35, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:

Gerben Wierda schrieb am = 29.03.2020 um 14:30:
On= 29 Mar 2020, at 12:58, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:

Gerben Wierda schrieb am 29.03.2020 um = 12:52:
I am using = MetaFun (Lua code) to create METAPOST commands from an XML file. One of = the issues I am running into that in METAPOST I have to handle strings = with " characters in them and METAPOST doesn=E2=80=99t like those. The = argument using the string
Foo "Bar=E2=80=9D Foo

    ^^^

Use correct left quotation marks or = \quotation{=E2=80=A6}.
I=E2=80=99m not hard = coding the string, I=E2=80=99m reading it from an XML. So, whatever I = do, I need to do it by manipulating the string.
E.g. if = the string I read contains
Foo "Bar=E2=80=9D Foo
your suggestion means  I have to programmatically change = that to
Foo \quotation{Bar} Foo
which is too = complicated, given that I don=E2=80=99t have regular expression replace = at my disposal.
I might be able to change al =E2=80=9C = instances into something else by walking through the string and building = a new one.

Your example uses " before Bar and not =E2=80=9C which is the = problem.

Yes, I am aware that that is my problem. It is = just that I do not have the luxury to decide myself what will be put in = the string. It must work for any string. So, I will have to be putting = that string to \type and make sure that is used as the = label.

G

= --Apple-Mail=_40C50356-2085-407C-9C98-9604EEF67FF5-- --===============6215093678753240181== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============6215093678753240181==--