ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Puzzle (for me)
@ 2020-03-31 23:20 Gerben Wierda
  2020-03-31 23:53 ` Henri Menke
  0 siblings, 1 reply; 3+ messages in thread
From: Gerben Wierda @ 2020-03-31 23:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

I have a string with double quotes that needs to become a text in a box in METAPOST. METAPOST is used to create an image consisting of boxes and connections.

Basically, the approach is now something like this:

TeX: calls Lua code with \ctxlua{filename}
Lua: context.startMPpage
Lua: read XML. String in XML in filename read by Lua
  Here we know the dimensions in which the string must be typeset and wrapped around because that is also in the XML
Lua: A context() call contains METAPOST code that calls a METAPOST vardef (‘draw box’) with the string as argument
METAPOST: Draws box and call TeX to typeset string using textext(), returns picture object
TeX: Typeset string

In short:
TeX, calls
	Lua, reads XML and executes context( MP code) that gets executed on stopMPpage
		MP code calls TeX which typesets the string

But, if the string contains double quotes (”) this will fail in METAPOST because the double quotes in the string will be printed in METAPOST code that is created by Lua and thus mess up METAPOST.

So, what can I do?

G
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Puzzle (for me)
  2020-03-31 23:20 Puzzle (for me) Gerben Wierda
@ 2020-03-31 23:53 ` Henri Menke
  2020-04-01 14:25   ` Gerben Wierda
  0 siblings, 1 reply; 3+ messages in thread
From: Henri Menke @ 2020-03-31 23:53 UTC (permalink / raw)
  To: ntg-context

On 01/04/20, 01:20, Gerben Wierda wrote:
> I have a string with double quotes that needs to become a text in a box in METAPOST. METAPOST is used to create an image consisting of boxes and connections.
> 
> Basically, the approach is now something like this:
> 
> TeX: calls Lua code with \ctxlua{filename}
> Lua: context.startMPpage
> Lua: read XML. String in XML in filename read by Lua
>   Here we know the dimensions in which the string must be typeset and wrapped around because that is also in the XML
> Lua: A context() call contains METAPOST code that calls a METAPOST vardef (‘draw box’) with the string as argument
> METAPOST: Draws box and call TeX to typeset string using textext(), returns picture object
> TeX: Typeset string
> 
> In short:
> TeX, calls
> 	Lua, reads XML and executes context( MP code) that gets executed on stopMPpage
> 		MP code calls TeX which typesets the string
> 
> But, if the string contains double quotes (”) this will fail in METAPOST because the double quotes in the string will be printed in METAPOST code that is created by Lua and thus mess up METAPOST.
> 
> So, what can I do?

To get a double quote in a MetaPost string like this

    "embedded " double quote"
              ^
              |___ oeps

use the ditto variable which expands to a string containing the double
quote character like so

    "embedded " & ditto & " double quote"

Cheers, Henri

> 
> G
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Puzzle (for me)
  2020-03-31 23:53 ` Henri Menke
@ 2020-04-01 14:25   ` Gerben Wierda
  0 siblings, 0 replies; 3+ messages in thread
From: Gerben Wierda @ 2020-04-01 14:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 3084 bytes --]



> On 1 Apr 2020, at 01:53, Henri Menke <henrimenke@gmail.com> wrote:
> 
> On 01/04/20, 01:20, Gerben Wierda wrote:
>> I have a string with double quotes that needs to become a text in a box in METAPOST. METAPOST is used to create an image consisting of boxes and connections.
>> 
>> Basically, the approach is now something like this:
>> 
>> TeX: calls Lua code with \ctxlua{filename}
>> Lua: context.startMPpage
>> Lua: read XML. String in XML in filename read by Lua
>>  Here we know the dimensions in which the string must be typeset and wrapped around because that is also in the XML
>> Lua: A context() call contains METAPOST code that calls a METAPOST vardef (‘draw box’) with the string as argument
>> METAPOST: Draws box and call TeX to typeset string using textext(), returns picture object
>> TeX: Typeset string
>> 
>> In short:
>> TeX, calls
>> 	Lua, reads XML and executes context( MP code) that gets executed on stopMPpage
>> 		MP code calls TeX which typesets the string
>> 
>> But, if the string contains double quotes (”) this will fail in METAPOST because the double quotes in the string will be printed in METAPOST code that is created by Lua and thus mess up METAPOST.
>> 
>> So, what can I do?
> 
> To get a double quote in a MetaPost string like this
> 
>    "embedded " double quote"
>              ^
>              |___ oeps
> 
> use the ditto variable which expands to a string containing the double
> quote character like so
> 
>    "embedded " & ditto & " double quote”

That is great! Thanks.

G

> 
> Cheers, Henri
> 
>> 
>> G
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>> 
>> maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context <http://www.ntg.nl/mailman/listinfo/ntg-context>
>> webpage  : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / http://context.aanhet.net <http://context.aanhet.net/>
>> archive  : https://bitbucket.org/phg/context-mirror/commits/ <https://bitbucket.org/phg/context-mirror/commits/>
>> wiki     : http://contextgarden.net <http://contextgarden.net/>
>> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context <http://www.ntg.nl/mailman/listinfo/ntg-context>
> webpage  : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / http://context.aanhet.net <http://context.aanhet.net/>
> archive  : https://bitbucket.org/phg/context-mirror/commits/ <https://bitbucket.org/phg/context-mirror/commits/>
> wiki     : http://contextgarden.net <http://contextgarden.net/>
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 21997 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-01 14:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31 23:20 Puzzle (for me) Gerben Wierda
2020-03-31 23:53 ` Henri Menke
2020-04-01 14:25   ` Gerben Wierda

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).