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