ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
To: Gerben Wierda <gerben.wierda@rna.nl>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: How do I handle strings with " characters in it in METAPOST?
Date: Sun, 29 Mar 2020 15:09:54 +0200	[thread overview]
Message-ID: <84b1bf6c-d34b-ec3a-d574-2d730c3e09c0@gmail.com> (raw)
In-Reply-To: <36E421F8-0294-4D04-8C45-0718B47E1727@rna.nl>

Gerben Wierda schrieb am 29.03.2020 um 15:06:
> 
> 
>> On 29 Mar 2020, at 14:35, Wolfgang Schuster 
>> <wolfgang.schuster.lists@gmail.com 
>> <mailto: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 
>>>> <mailto: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’t like those. The argument using the string
>>>>> Foo "Bar” Foo
>>>>
>>>>     ^^^
>>>>
>>>> Use correct left quotation marks or \quotation{…}.
>>> I’m not hard coding the string, I’m 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” Foo
>>> your suggestion means  I have to programmatically change that to
>>> Foo \quotation{Bar} Foo
>>> which is too complicated, given that I don’t have regular expression 
>>> replace at my disposal.
>>> I might be able to change al “ instances into something else by 
>>> walking through the string and building a new one.
>>
>> Your example uses " before Bar and not “ 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.

Does btex .. etex help or can't you change the strings and replace the 
quotation marks before you pass them to MetaPost?

\starttext

\startMPcode
draw textext.urt("One");
draw btex "Two" etex shifted (0,15);
label.urt("Three",(0,30));
label.urt(btex "Four" etex,(0,45));
\stopMPcode

\stoptext

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2020-03-29 13:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-29 10:52 Gerben Wierda
2020-03-29 10:58 ` Wolfgang Schuster
2020-03-29 12:30   ` Gerben Wierda
2020-03-29 12:35     ` Wolfgang Schuster
2020-03-29 13:06       ` Gerben Wierda
2020-03-29 13:09         ` Wolfgang Schuster [this message]
2020-03-29 14:25           ` Gerben Wierda

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=84b1bf6c-d34b-ec3a-d574-2d730c3e09c0@gmail.com \
    --to=wolfgang.schuster.lists@gmail.com \
    --cc=gerben.wierda@rna.nl \
    --cc=ntg-context@ntg.nl \
    /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).