ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Lua/TeX/METAPOST/textext string issue/puzzle
@ 2020-04-01 19:34 Gerben Wierda
  2020-04-01 21:44 ` Aditya Mahajan
  0 siblings, 1 reply; 3+ messages in thread
From: Gerben Wierda @ 2020-04-01 19:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

I have lua code that generates this for METAPOST:

ApplicationComponentLogo( w, h, "withcolor (0.686,1.000,1.000) withtransparency (1,0.200)", "withcolor (0.000,0.000,0.000) withtransparency (1,1.000) withpen pencircle scaled 1.000", "\{Hello\}, "&ditto&"(a)"&ditto&" [World]!") shifted (x, -y); draw pic;

The string to be typeset, eventually is this: 

{Hello}, "(a)" [World]!

So, with double quotes in the string. The function creating the actual string to pass to METAPOST (above) is this:

local function mpLabelString( xmlLabelString)
  -- Returns a string where each " is replaced by a METAPOST compatible result, except for outer double quotes"
  rep = {
      [1] = { "\"", "\"&ditto&\""   },
  }
  local tmpString = string.formatters( "%!tex!", xmlLabelString)
  return lpeg.replacer(rep):match(tmpString)
end

That works. Then, in METAPOST the vardef ‘ApplicationComponentLogo’  calls a vardef makeTeXLabel 

draw makeTeXLabel( w, h, name) shifted (w/2,0);

which, for now, simplified does this:

vardef makeTeXLabel( expr w, h, name) =
  save p; picture p ;
  save s; string s;
  s := "\framed{" & name & "}”;
  % s := "\type-" & name & "-";
  p := textext( s);
  p
enddef;

But, this is what is in string s before it is sent to textext():

\framed {{Hello}, "(a)" [World]!}

In other words, the escapes on the curly braces are lost and now the curly braces are ignored by TeX. 

I tried adding a doubling of the backslahes to the replacement:

  rep = {
      [1] = { "\"", "\"&ditto&\""   },
      [2] = { "\\", "\\\\" },
  }

But then the string that is typeset (and given to textext()) becomes 

\framed {\\{Hello\\}, "(a)" [World]!}

And the result in the output is the same. No curly braces.

My route is probably to complex anyway, but what can I do for the curly braces to be actually typeset?

G

[-- Attachment #1.2: Type: text/html, Size: 5506 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

* Re: Lua/TeX/METAPOST/textext string issue/puzzle
  2020-04-01 19:34 Lua/TeX/METAPOST/textext string issue/puzzle Gerben Wierda
@ 2020-04-01 21:44 ` Aditya Mahajan
  2020-04-02  9:52   ` Gerben Wierda
  0 siblings, 1 reply; 3+ messages in thread
From: Aditya Mahajan @ 2020-04-01 21:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Wed, 1 Apr 2020, Gerben Wierda wrote:
>
> My route is probably to complex anyway, but what can I do for the curly braces to be actually typeset?

MkII had a feature called \sometxt
http://dl.contextgarden.net/myway/sometxt.pdf

I wonder if that still works in MkIV.

Aditya
___________________________________________________________________________________
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: Lua/TeX/METAPOST/textext string issue/puzzle
  2020-04-01 21:44 ` Aditya Mahajan
@ 2020-04-02  9:52   ` Gerben Wierda
  0 siblings, 0 replies; 3+ messages in thread
From: Gerben Wierda @ 2020-04-02  9:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Actually, the backslashes disappear before the call to textext()

G

> On 1 Apr 2020, at 23:44, Aditya Mahajan <adityam@umich.edu> wrote:
> 
> On Wed, 1 Apr 2020, Gerben Wierda wrote:
>> 
>> My route is probably to complex anyway, but what can I do for the curly braces to be actually typeset?
> 
> MkII had a feature called \sometxt
> http://dl.contextgarden.net/myway/sometxt.pdf
> 
> I wonder if that still works in MkIV.
> 
> Aditya
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 1764 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-02  9:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 19:34 Lua/TeX/METAPOST/textext string issue/puzzle Gerben Wierda
2020-04-01 21:44 ` Aditya Mahajan
2020-04-02  9:52   ` 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).