[NTG-context] \setupinteraction[style=...] supersedes manual text style for \note

2020-04-01 Thread Benjamin Buchmuller
For the following one, I’m not sure if this is the intended behaviour or not:

I want to set up the “notation” and “note” style manually, which works great 
unless I also call \setupinteraction[state=start,style=normal] (or any other 
style), regardless of calling it before or after setting up “notation” or 
“note”.

MWE (with an assortment of different note positions):

% \setupinteraction[state=start,style=normal] %% uncomment and manual style for 
\note[] is no longer respected

\setupnotes[textcolor=blue,textstyle=italic]
\setupnotation[endnote][headcolor=green,numberconversion=character]

\starttext
This is the footnote\footnote[one]{aha} and the reference\note[one].

This is the endnote\endnote[two]{oho} and the reference\note[endnote][two].

Let's look \in[one].

\startplacefigure[title={And in this float\endnote[three]{hmm} and the 
reference\note[three].}]

\externalfigure[cow]

\stopplacefigure

\page

And look here \in[two].

\placenotes[endnote]
\stoptext

Cheers


Benjamin
___
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
___


Re: [NTG-context] Lua/TeX/METAPOST/textext string issue/puzzle

2020-04-01 Thread Aditya Mahajan

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
___


[NTG-context] Lua/TeX/METAPOST/textext string issue/puzzle

2020-04-01 Thread Gerben Wierda
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\}, "&"(a)"&" [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] = { "\"", "\"&\""   },
  }
  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] = { "\"", "\"&\""   },
  [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___
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
___


Re: [NTG-context] Puzzle (for me)

2020-04-01 Thread Gerben Wierda


> On 1 Apr 2020, at 01:53, Henri Menke  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  / 
>> 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 
> ___

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