Re: [NTG-context] Trying to understand this ctxlua error

2020-04-05 Thread Wolfgang Schuster

Gerben Wierda schrieb am 06.04.2020 um 00:41:

I got this error after I had changed some lua code:

tex error       > tex error on line 272 in file archimate-lua.new: ! 
Undefined control sequence


         warnIfVerbose( "Breaking off the processing of node %s\nNo
       l...eak  
           xsi:type", node)
\luat_start_lua_code_indeed ...ormalexpanded {\endgroup \noexpand 
\directlua {#1
 
         }}

l.272 \stopluacode






The control sequence at the end of the top line of your error message 
was never

\def'ed. You can just continue as I'll forget about whatever was undefined.

I have been looking at that code for over two hours, not seeing anything 
wrong with it. But I’ve now finally found the culprit and I still do not 
get it.


The culprit was:

           warnIfVerbose( "Breaking off the processing of %s\n No 
elementRef", node)


The problem goes away when I use:

           warnIfVerbose( "Breaking off the processing of %s\nNo 
elementRef", node)


(I don’t want the line after the node is printed to begin with a space).

But the lack of space between \n and N kills lua (apparently). For 
completeness (as string.format and texio.write_nl are also in play):


function warnWithLabelIfVerbose( str, ... )
   if verboseProgram then
     texio.write_nl( str .. string.format(...))
   end
end

function warnIfVerbose( ... )
   warnWithLabelIfVerbose("-> ", ...)
end

Is this a lua bug? A ConTeXt bug? Expected behaviour? And if so, why is 
reported that on line 272 (where \stopluacode is) is the error? Or is 
the error message indeed helpful and do I just lack the know how to 
interpret it?


ConTeXt expands TeX commands in a luacode-environment
and when you have \n followed by text you create a new
command with starts with \n but since it isn't defined
you get a error message.

In the example below the commented block produces
the same error message as you get.

\starttext

%\startluacode
%print("text\ntext")
%\stopluacode

\startluacode
print("text\n text")
\stopluacode

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


[NTG-context] Trying to understand this ctxlua error

2020-04-05 Thread Gerben Wierda
I got this error after I had changed some lua code:

tex error   > tex error on line 272 in file archimate-lua.new: ! Undefined 
control sequence

warnIfVerbose( "Breaking off the processing of node %s\nNo 
  l...eak   
 xsi:type", node)
\luat_start_lua_code_indeed ...ormalexpanded {\endgroup \noexpand \directlua {#1

}}
l.272 \stopluacode





The control sequence at the end of the top line of your error message was never
\def'ed. You can just continue as I'll forget about whatever was undefined.

I have been looking at that code for over two hours, not seeing anything wrong 
with it. But I’ve now finally found the culprit and I still do not get it.

The culprit was:

  warnIfVerbose( "Breaking off the processing of %s\n No elementRef", 
node)

The problem goes away when I use:

  warnIfVerbose( "Breaking off the processing of %s\nNo elementRef", 
node)

(I don’t want the line after the node is printed to begin with a space).

But the lack of space between \n and N kills lua (apparently). For completeness 
(as string.format and texio.write_nl are also in play):

function warnWithLabelIfVerbose( str, ... )
  if verboseProgram then
texio.write_nl( str .. string.format(...))
  end
end

function warnIfVerbose( ... )
  warnWithLabelIfVerbose("-> ", ...)
end

Is this a lua bug? A ConTeXt bug? Expected behaviour? And if so, why is 
reported that on line 272 (where \stopluacode is) is the error? Or is the error 
message indeed helpful and do I just lack the know how to interpret it?

G

(Took me three hours, this one. Just removing that space that happened with 
some other changes was the culprit. Totally unexpected for me.)___
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] Bounding box of picture returned by textext() in METAPOST

2020-04-05 Thread Gerben Wierda
Nobody?

> On 4 Apr 2020, at 22:58, Gerben Wierda  wrote:
> 
> I have this METAPOST macro:
> 
> vardef makeTeXLabel( expr w, h, name) =
>   if debugProgram or debugLabels: show "NAME makeTeXLabel:", name, tostring 
> 0.8w, tostring 0.8h; fi
>   save p; picture p;
>   p := textext( "\startframedtext[middle]" &
> "[align=middle,frame=on" &
> ",width=" & tostring 0.8w & "bp" &
> ",height=" & tostring 0.8h & "bp]" &
> name & "\stopframedtext");
>   save b; path b; b := boundingbox p;
>   save dim; pair dim;
>   dim := (urcorner b) - (llcorner b);
>   save width, height; numeric width, height;
>   width := xpart dim;
>   height = ypart dim;
>   if debugLabels: show "PLACE:", w, h, width, height; fi
>   if (width > 0.8w) or (height > 0.8h):
> if (width > height):
>   if debugLabels: show "XSCALING:", (0.8w/width,0.8w/width); fi
>   p:= p xyscaled (0.8w/width,0.8w/width);
> else:
>   if debugLabels: show "YSCALING:", (0.8h/height,0.8h/height); fi
>   p:= p xyscaled (0.8h/height,0.8h/height);
> fi
>   fi
>   p
> enddef;
> 
> It gets called with w=133 and h=53 (I am working in METAPOST native units, so 
> bp)
> 
> So, the textext() command gets something like 106bp x 42bp, which seems to be 
> the case:
> 
> metapost log> >> "NAME makeTeXLabel:"
> metapost log> >> "My 'Application' Function"
> metapost log> >> "106.41"
> cld > tex > w : - : \MPLIBsetNtextX{1}{\startframedtext 
> [middle][align=middle,frame=on,width=106.41bp,height=42.406bp]My
>  'Application' Function\stopframedtext }
> cld > tex > F : - : \startblankhandling
> cld > tex > w : - : \setblankcategory{6}
> cld > tex > F : - : \flushblankhandling
> cld > tex > F : - : \stopblankhandling
> metapost log> >> "42.406"
> metapost log> >> "PLACE:"
> metapost log> >> 133
> metapost log> >> 53
> metapost log> >> 511.0865990822
> metapost log> >> 42.3051402
> 
> But the bounding box is 511bp wide (something like 7in or 18cm, probably 
> textwidth) but I’m asking for a box that is 106bp wide.
> 
> What happens here? And how do I get it right? 
> 
> 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
___


Re: [NTG-context] Using Lua files in project structure

2020-04-05 Thread Aditya Mahajan

On Sun, 5 Apr 2020, Jairo A. del Rio wrote:


I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua
libraries and bindings (defining \ctxlua and the like). For instance, I
have the file foo.lua with some macros and I want to use them in my
project. Something like this:

\startproject project
%\component foo.lua %This does not work
%\environment foo.lua %This does not work
%\input foo.lua %This does not work
%\directlua{dofile("foo.lua")} %This does not work even when the project
file and foo.lua are in the same folder.
\stopproject


I have been \environment foo.lua for an old project (which 
has been running without significant changes for about 10 years now). I 
tested it again, and it is working on LMTX 2019.12.31.


Has something changed in the recent versions? (I should upgrade and check)

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
___


Re: [NTG-context] Using Lua files in project structure

2020-04-05 Thread Wolfgang Schuster

Jairo A. del Rio schrieb am 05.04.2020 um 17:49:

None of them work. Maybe I'm doing something wrong.


I guess so because

\loadluafile[testh.lua]

and

\luaenvironment testh.lua

work for me.

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
___


[NTG-context] Is there a robust way to find the first (or last intersection) of path p with path q?

2020-04-05 Thread Gerben Wierda
Intersecting path p and q will give you more or less randomly (actually, there 
is an algorithm, but not a very useful one for METAPOST) an intersection (time 
on p, time on q)

I am trying to find out if anybody as already created a macro that gives you 
the intersection with the smallest (or largest) time on p. Probably requires 
finding all the intersections and then returning either the point on p with 
minimum (or maximum) t.

Before writing myself, maybe someone already has this, in which case thanks in 
advance.

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] Using Lua files in project structure

2020-04-05 Thread Jairo A. del Rio
None of them work. Maybe I'm doing something wrong.

I have my project file (say, "main.tex") in a folder (say, "Main") and
projects in a subfolder (say "Products").
I've written some Lua macros in a file (say, "foo.lua") and I need all the
products to be able to call those Lua functions, so I tried loading them in
the project file ("foo.lua" and "main.tex" are in the same folder, whereas
products are in the subfolder). \usepath works for finding other files,
such as images, so I don't know what is going on. I'm attaching a test
project.

El dom., 5 de abr. de 2020 a la(s) 09:28, Wolfgang Schuster (
wolfgang.schuster.li...@gmail.com) escribió:

> Jairo A. del Rio schrieb am 05.04.2020 um 15:00:
> > I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua
> > libraries and bindings (defining \ctxlua and the like). For instance, I
> > have the file foo.lua with some macros and I want to use them in my
> > project. Something like this:
> >
> > \startproject project
> > %\component foo.lua %This does not work
> > %\environment foo.lua %This does not work
> > %\input foo.lua %This does not work
> > %\directlua{dofile("foo.lua")} %This does not work even when the project
> > file and foo.lua are in the same folder.
> > \stopproject
> >
> > What should I do? Thank you in advance.
>
> 1. \luaenvironment 
>
> 2. \useluamodule []
>
> 3. \ctxloadluafile {}
>
> 4. \loadluafile [] or \loadluafileonce []
>
> 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
___


Re: [NTG-context] Using Lua files in project structure

2020-04-05 Thread Wolfgang Schuster

Jairo A. del Rio schrieb am 05.04.2020 um 15:00:
I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua 
libraries and bindings (defining \ctxlua and the like). For instance, I 
have the file foo.lua with some macros and I want to use them in my 
project. Something like this:


\startproject project
%\component foo.lua %This does not work
%\environment foo.lua %This does not work
%\input foo.lua %This does not work
%\directlua{dofile("foo.lua")} %This does not work even when the project 
file and foo.lua are in the same folder.

\stopproject

What should I do? Thank you in advance.


1. \luaenvironment 

2. \useluamodule []

3. \ctxloadluafile {}

4. \loadluafile [] or \loadluafileonce []

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
___


Re: [NTG-context] Using Lua files in project structure

2020-04-05 Thread Thomas A. Schmitz

On 05.04.20 15:00, Jairo A. del Rio wrote:
I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua 
libraries and bindings (defining \ctxlua and the like). For instance, I 
have the file foo.lua with some macros and I want to use them in my 
project. Something like this:


\startproject project
%\component foo.lua %This does not work
%\environment foo.lua %This does not work
%\input foo.lua %This does not work
%\directlua{dofile("foo.lua")} %This does not work even when the project 
file and foo.lua are in the same folder.

\stopproject

What should I do? Thank you in advance.


Have you tried

\registerctxluafile{foo}{} ?

That's the way context loads its lua files.

Thomas
___
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] xhtml export internal command \dostarttaging modify display and other XML/XHTML attributes

2020-04-05 Thread Christoph Hintermüller
Hi
I'm helping to make t-vim module fully usable in xhtml and futher epub
export. Getting a distingct tag for the individual lines was quiet easy
to do using \dostarttagged and \dostoptagged internal macros.
What i'm not able to figure are the following things:
1) How can i set/modify the display attribute of the resulting
div.myclass section in the generated *_templates.css file.
Per default the display attribute is set to "inline" while i need
"block" or "flex" (not jet decided" which).
2) How can i predefine the white-space css attribute to pre-wrap 
3) Is there a way to tell context to include the resulting class inside
the *.default.css or *.styles.css or should that be done via the css
parameter of the \setupbackend macro only?

Best
Xristoph


___
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] What was that 'rounding paths' metafun(?) function again?

2020-04-05 Thread Gerben Wierda


> On 5 Apr 2020, at 15:24, Keith McKay  wrote:
> 
> Would sections 1.3, 1.18, 2.5 and 2.6 in the Metafun manual help?

I used what is in 1.3 (though I actually used Peter Grogono’s PDF MetaPost: A 
Reference Manual  
which I find the best educational document about plain METAPOST so far).

1.18 was what I was looking for but did not work in my situation (don’t know 
why, but it exploded). I fixed another issue (calling cornering on top of 
cornering when doing recursion) and that made my own macro behave perfectly 
civilised.

I had looked at 2.5 and 2.6 but this was not required (nor of any use).

G

> 
> Keith
> 
> On 05/04/2020 11:31, Gerben Wierda wrote:
>> I think I saw a function in MetaFun somehwre that you could give a ‘hard’ 
>> path, i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely 
>> rounded (part of a circle) corners (still straight lines), but I can’t find 
>> it anymore. I wrote my own, but it is giving me headaches so I’d like to 
>> find something that is better than what I produce.
>> 
>> 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
___


Re: [NTG-context] Using Lua files in project structure

2020-04-05 Thread mf

Il 05/04/20 15:00, Jairo A. del Rio ha scritto:
I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua 
libraries and bindings (defining \ctxlua and the like). For instance, I 
have the file foo.lua with some macros and I want to use them in my 
project. Something like this:


\startproject project
%\component foo.lua %This does not work
%\environment foo.lua %This does not work
%\input foo.lua %This does not work
%\directlua{dofile("foo.lua")} %This does not work even when the project 


\directlua{require("foo")}

or

\startluacode
  require("foo")
\stopluacode


file and foo.lua are in the same folder.
\stopproject

What should I do? Thank you in advance.


Best wishes,
Massi
___
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] What was that 'rounding paths' metafun(?) function again?

2020-04-05 Thread Keith McKay

Would sections 1.3, 1.18, 2.5 and 2.6 in the Metafun manual help?

Keith

On 05/04/2020 11:31, Gerben Wierda wrote:

I think I saw a function in MetaFun somehwre that you could give a ‘hard’ path, 
i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely rounded 
(part of a circle) corners (still straight lines), but I can’t find it anymore. 
I wrote my own, but it is giving me headaches so I’d like to find something 
that is better than what I produce.

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
___


[NTG-context] Using Lua files in project structure

2020-04-05 Thread Jairo A. del Rio
I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua
libraries and bindings (defining \ctxlua and the like). For instance, I
have the file foo.lua with some macros and I want to use them in my
project. Something like this:

\startproject project
%\component foo.lua %This does not work
%\environment foo.lua %This does not work
%\input foo.lua %This does not work
%\directlua{dofile("foo.lua")} %This does not work even when the project
file and foo.lua are in the same folder.
\stopproject

What should I do? Thank you in advance.
___
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] What was that 'rounding paths' metafun(?) function again?

2020-04-05 Thread Gerben Wierda
Yes, I meant cornered.

But it turns out it works worse in my case, I get paths with hundreds of 
segments and a run that goes amok. But that made me find a mistake in my code 
and now I’m using my own again and it works fine:

vardef softenPath( expr hardPath) =
  save softPath; path softPath;
  save len; len := length hardPath;
  save rounding; rounding := 5;
  save i;
  for i=0 upto len:
if (i=0):
  % first pair
  softPath := point i of hardPath;
elseif (i=len):
  % lastpair
  softPath := softPath -- point i of hardPath;
else:
  % intermediate pair
  save subOne; path subOne; subOne := subpath(i-1, i) of hardPath;
  save subTwo; path subTwo; subTwo := subpath(i, i+1) of hardPath;
  save lenOne; numeric lenOne; lenOne := arclength subOne;
  save lenTwo; numeric lenTwo; lenTwo := arclength subTwo;
  save pointOne, pointTwo; pair pointOne, pointTwo;
  pointOne := point (arctime (lenOne-rounding) of subOne) of subOne;
  pointTwo := point (arctime rounding of subTwo) of subTwo;
  save dirOne, dirTwo; pair dirOne, dirTwo;
  dirOne := direction (arctime (lenOne-rounding) of subOne) of subOne;
  dirTwo := direction (arctime (rounding) of subTwo) of subTwo;
  softPath := softPath -- pointOne{dirOne} .. {dirTwo}pointTwo;
fi
  endfor;
  softPath
enddef;

Fixed rounding of 5bp, but that is easy to change.

> On 5 Apr 2020, at 12:37, Wolfgang Schuster 
>  wrote:
> 
> Gerben Wierda schrieb am 05.04.2020 um 12:31:
>> I think I saw a function in MetaFun somehwre that you could give a ‘hard’ 
>> path, i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely 
>> rounded (part of a circle) corners (still straight lines), but I can’t find 
>> it anymore. I wrote my own, but it is giving me headaches so I’d like to 
>> find something that is better than what I produce.
> 
> You you mean "cornered ..." or "smoothed ..."?
> 
> 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
___


Re: [NTG-context] What was that 'rounding paths' metafun(?) function again?

2020-04-05 Thread Wolfgang Schuster

Gerben Wierda schrieb am 05.04.2020 um 12:31:

I think I saw a function in MetaFun somehwre that you could give a ‘hard’ path, 
i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely rounded 
(part of a circle) corners (still straight lines), but I can’t find it anymore. 
I wrote my own, but it is giving me headaches so I’d like to find something 
that is better than what I produce.


You you mean "cornered ..." or "smoothed ..."?

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
___


[NTG-context] What was that 'rounding paths' metafun(?) function again?

2020-04-05 Thread Gerben Wierda
I think I saw a function in MetaFun somehwre that you could give a ‘hard’ path, 
i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely rounded 
(part of a circle) corners (still straight lines), but I can’t find it anymore. 
I wrote my own, but it is giving me headaches so I’d like to find something 
that is better than what I produce.

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] startMPpage..stopMPpage written to a separate PDF?

2020-04-05 Thread Gerben Wierda


> On 5 Apr 2020, at 11:34, Hans Hagen  wrote:
> 
> On 4/5/2020 12:29 AM, Gerben Wierda wrote:
>> I have a series of startMPpage—stopMPpage pairs (with MP code inbetween). 
>> These now become separate pages in a single PDF. But I need them to become 
>> separate PDF’s each during my ConTeXt run, with a name of my own choosing. 
>> Is this possible? I guess this will be problematic, but one can hope (maybe 
>> some very low level TeX trickery)...
> no (i would probably cook up something but it's not worth the trouble and it 
> would add lots of ugly code deep down) but

Yes, I was thinking about some low level open/writeout stuff in TeX but was 
scared to try.

Still, a \startMPfile{pdffilename}..\stopMPfile (instead of page) would have 
been great...

> you can use for instance mutool etc to split pdf’s

I can’t do that simply because it would mean lots and lots of manual work 
(including typing long names every time) each time I automatically produce the 
PDFs. I am talking hundreds of views generated anew every time and they all 
need to end up in a separate file. I need some sort of automatic flow. It’s OK 
if the PDF with all the pages is an intermediate and use a tool to split this 
into separate files with separate file names (so an additional step in the 
workflow) but I would have to create th eextraction script automatically during 
the ConTeXt run. 

Alternatively, I could have a step before this to turn the input XML into many 
separate XMLs and have many ConTeXt runs. Probably that is the best way to do 
it. Each generated XML would have all of the original XML except it would only 
have one ‘view’ in it and the rest removed.

> 
> Hans
> 
> -
>  Hans Hagen | PRAGMA ADE
>  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -

___
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] Solved: Minimum example of problem getting curly braces printed in METAPOST

2020-04-05 Thread Hans Hagen

On 4/3/2020 5:36 PM, Gerben Wierda wrote:

Thanks to Taco, the solution was to simply use:

function doubleQuotableEscapedConTeXtString( str)
   local rep = {
       [1] =  { '{', '{\\textbraceleft}' },
       [2] =  { '}', '{\\textbraceright}' },
       [3] =  { '#', '{\\texthash}' },
       [4] =  { '$', '{\\textdollar}' },
       [5] =  { '&', '{\\textampersand}' },
       [6] =  { '%', '{\\textpercent}' },
       [7] =  { '\\','{\\textbackslash}' },
       [8] =  { '|', '{\\textbar}' },
       [9] =  { '_', '{\\textunderscore}' },
       [10] = { '~', '{\\textasciitilde}' },
       [11] = { '^', '{\\textasciicircum}' },
       [12] = { '"', "\"&\"" },
   }
   return lpeg.replacer(rep):match(str)
end

And the string becomes something that can safely be given toi METAPOST 
and safely handled by TeX when called from METAPOST via textext()

more efficient

local rep = lpeg.replacer {
  { '{', '{\\textbraceleft}' },
  { '}', '{\\textbraceright}' },
  { '#', '{\\texthash}' },
  { '$', '{\\textdollar}' },
  { '&', '{\\textampersand}' },
  { '%', '{\\textpercent}' },
  { '\\','{\\textbackslash}' },
  { '|', '{\\textbar}' },
  { '_', '{\\textunderscore}' },
  { '~', '{\\textasciitilde}' },
  { '^', '{\\textasciicircum}' },
  { '"', "\"&\"" },
}

function doubleQuotableEscapedConTeXtString( str)
return rep:match(str)
end

this is probably also ok:

local rep = {
["\""] = "\\char34 ",
["#"]  = "\\char35 ",
["$"]  = "\\char36 ",
["%"]  = "\\char37 ",
["&"]  = "\\char38 ",
["\\"] = "\\char92 ",
["^"]  = "\\char94 ",
["_"]  = "\\char95 ",
["{"]  = "\\char123 ",
["|"]  = "\\char124 ",
["}"]  = "\\char125 ",
["~"]  = "\\char126 ",
}

function doubleQuotableEscapedConTeXtString(str)
return (string.gsub(str,".",rep))
end


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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] startMPpage..stopMPpage written to a separate PDF?

2020-04-05 Thread Hans Hagen

On 4/5/2020 12:29 AM, Gerben Wierda wrote:

I have a series of startMPpage—stopMPpage pairs (with MP code inbetween). These 
now become separate pages in a single PDF. But I need them to become separate 
PDF’s each during my ConTeXt run, with a name of my own choosing. Is this 
possible? I guess this will be problematic, but one can hope (maybe some very 
low level TeX trickery)...
no (i would probably cook up something but it's not worth the trouble 
and it would add lots of ugly code deep down) but you can use for 
instance mutool etc to split pdf's


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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] lmtx vs mkiv

2020-04-05 Thread Axel Kielhorn


> Am 03.04.2020 um 11:07 schrieb Hans Hagen :
> 
> For that reason the latest lmtx installer now (for the time being) also 
> includes the luatex binary (plus mkiv files needed) so that one can install 
> lmtx and run both engines. Instead of the --luatex switch one can also force 
> the engine in the usual way with "% engine=luatex" at the top line of the 
> source file (but no pdftex and xetex in this installer).

I updated LMTX on MacOSX 10.13 today.

The luatex binary in not executable, thus when I run

axel$ context --luatex --version
mtx-context | redirect luametatex -> luatex: luatex --luaonly 
"/usr/local/texlive/LMTX/tex/texmf-osx-64/bin/mtxrun.lua" --script mtx-context 
--luatex --version --redirected
mtx-context | ConTeXt Process Management 1.02
mtx-context |
mtx-context | main context file: /Volumes/Macintosh 
HD/usr/local/texlive/2019/texmf-dist/tex/context/base/mkiv/context.mkiv
mtx-context | current version: 2019.03.21 21:39

it picks up the TeX-Live version.

after I 

axel$ chmod 744 luatex 

I get the correct version:

axel$ context --luatex --version
mtx-context | redirect luametatex -> luatex: luatex --luaonly 
"/usr/local/texlive/LMTX/tex/texmf-osx-64/bin/mtxrun.lua" --script mtx-context 
--luatex --version --redirected
mtx-context | ConTeXt Process Management 1.03
mtx-context |
mtx-context | main context file: /Volumes/Macintosh 
HD/usr/local/texlive/LMTX/tex/texmf-context/tex/context/base/mkiv/context.mkiv
mtx-context | current version: 2020.04.03 10:31
mtx-context | main context file: /Volumes/Macintosh 
HD/usr/local/texlive/LMTX/tex/texmf-context/tex/context/base/mkiv/context.mkxl
mtx-context | current version: 2020.04.03 10:31

Greetings
Axel

___
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] splitted xtable with repeating headers and placetable

2020-04-05 Thread Wolfgang Schuster

Geert Dobbels schrieb am 05.04.2020 um 00:30:

Wolfgang,

Below is what I think is the bare minimum to explain this question 
(sorry for not doing it right from the beginning...)


Keep it up.

As I said, with the code as it is below, the header is not repeated 
after the first page, but the table is in the right place.


Replacing "split=yes" by "split=repeat" makes the header repeat 
correctly but puts the beginning of the table on the next page, leaving 
the first page nearly completely blank.


I already reported the problem on the dev-list. The reason is that
ConTeXt creates one big table and splits it afterwards in smaller
parts which fit on each page but when you use "split=repeat" the
part for the first page is too large to fit.

In both cases, the "header=repeat" setting has no influence at all on 
the behaviour and can be omitted without changing the results.


As I read in some other posts, sometimes putting the table in a float 
can help, so I tried this (by removing the 3 "%" in the code below), but 
there seems to be a conflict with the figure in the page header, and it 
stops with an error message.


Don't use floats in the header or footer, they serve no purpose
and you can include images without it. Below is a solution
with nested frames but you can also use a table to create
the header layout.

However, replacing the figure in the page header by a normal text 
suddenly solves the problem: putting "split" in the setupfloat and 
"header=repeat" in the setupxtable gives me a table with repeated 
headers that starts exactly where I want it to start. Apparently in this 
case, the "headers=repeat" is necessary. Unfortunately, I need a company 
logo up in the page header, which is what causes the error for which I 
have no explanation.


Here is a working version of your example but you have to a space
between the header and the page body (see headerdistance setting)
or reduce the height of the outer most frame (it uses at the moment
the height and width of the header area).

\setuppapersize[A4,landscape]

\setuplayout
  [location=middle,
   width=27.5cm,
   height=18cm,
   backspace=1cm,
   header=4cm,
   headerdistance=5mm]

\startsetups[header]
\startframed[width=max,height=max,frame=off,offset=overlay]
\startframed[height=1cm,width=max,frame=off]
\userpagenumber
\stopframed
\par
\startframed[height=3cm,width=max,offset=overlay]
\startframed[width=0.25\hsize,height=max]
\externalfigure[dummy][height=1.9cm]
\stopframed
\startframed[width=0.50\hsize,height=max,] % 
frame=off,topframe=on,bottomframe=on

some text in the middle block
\stopframed
\startframed[width=0.25\hsize,height=max]
some text in the right block
\stopframed
\stopframed
\stopframed
\stopsetups

\setupheadertexts[\directsetup{header}]

\startbuffer[tablerow]
\startxrow
\startxcell first \stopxcell
\startxcell second \stopxcell
\stopxrow
\stopbuffer

\startbuffer[table]
\startxtable
\startxtablehead[head]
\getbuffer[tablerow]
\stopxtablehead
\startxtablebody
\dorecurse{40}{\getbuffer[tablerow]}
\stopxtablebody
\stopxtable
\stopbuffer

\setupxtable
  [option=stretch,
   split=repeat,
   header=repeat,
   align=middle]

\setupxtable
  [head]
  [background=color,
   backgroundcolor=gray]

\starttext

\title{Table without float environment}

\samplefile{ward}

\getbuffer[table]

\title{Table with  float environment}

\samplefile{ward}

\startplacetable[location={none,split}]
\getbuffer[table]
\stopplacetable

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