Re: [NTG-context] Processing XML file inside a zip file

2019-01-10 Thread Aditya Mahajan

On Fri, 11 Jan 2019, Henri Menke wrote:


On 11/01/19 4:42 PM, Aditya Mahajan wrote:

Hi,

Is it possible to process an XML file inside a zip file without unzipping?

In particular, I have a program that generates zip files which look like
this:

The file `filename.zip` contains:
- filename.xml - file_hash1.png
- file_hash2.png
etc.

Where `filename.xml` (the name matches the basename of the zip file) is
the main xml file and the `file_hash1.png` etc are png files that are
referred to inside the xml file.

If I unzip the file and add

\setupexternalfigures[directory={path-to-unzipped-folder]

then, I have an \startxmlsetups .. \stopxmlsetups environment that
correctly typesets the xml file. I believe that I have seen Hans post
snippets of code that suggest that context can directly read from a zip
file. So, I am wondering if there is a way that I can just call

context --magic-flags filename.zip


You can directly typeset ePub files which is just zipped XML.  There is
a script in mtxrun for it:

   context --ctx=x-epub.ctx yourfile.epub

Documented in: http://www.pragma-ade.nl/general/manuals/hybrid.pdf


Thanks. But I could not find `x-epub.ctx` file in the standalone 
distribution.


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] Processing XML file inside a zip file

2019-01-10 Thread Henri Menke
On 11/01/19 4:42 PM, Aditya Mahajan wrote:
> Hi,
> 
> Is it possible to process an XML file inside a zip file without unzipping?
> 
> In particular, I have a program that generates zip files which look like
> this:
> 
> The file `filename.zip` contains:
> - filename.xml - file_hash1.png
> - file_hash2.png
> etc.
> 
> Where `filename.xml` (the name matches the basename of the zip file) is
> the main xml file and the `file_hash1.png` etc are png files that are
> referred to inside the xml file.
> 
> If I unzip the file and add
> 
> \setupexternalfigures[directory={path-to-unzipped-folder]
> 
> then, I have an \startxmlsetups .. \stopxmlsetups environment that
> correctly typesets the xml file. I believe that I have seen Hans post
> snippets of code that suggest that context can directly read from a zip
> file. So, I am wondering if there is a way that I can just call
> 
> context --magic-flags filename.zip

You can directly typeset ePub files which is just zipped XML.  There is
a script in mtxrun for it:

context --ctx=x-epub.ctx yourfile.epub

Documented in: http://www.pragma-ade.nl/general/manuals/hybrid.pdf

> 
> and obtain the correct output.
> 
> Thanks,
> 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
> ___

___
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] Processing XML file inside a zip file

2019-01-10 Thread Aditya Mahajan

Hi,

Is it possible to process an XML file inside a zip file without unzipping?

In particular, I have a program that generates zip files which look like 
this:


The file `filename.zip` contains:
- filename.xml 
- file_hash1.png

- file_hash2.png
etc.

Where `filename.xml` (the name matches the basename of the zip file) is 
the main xml file and the `file_hash1.png` etc are png files that are 
referred to inside the xml file.


If I unzip the file and add

\setupexternalfigures[directory={path-to-unzipped-folder]

then, I have an \startxmlsetups .. \stopxmlsetups environment that 
correctly typesets the xml file. I believe that I have seen Hans post 
snippets of code that suggest that context can directly read from a zip 
file. So, I am wondering if there is a way that I can just call


context --magic-flags filename.zip

and obtain the correct output.

Thanks,
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] XML and math

2019-01-10 Thread Aditya Mahajan

On Thu, 10 Jan 2019, Aditya Mahajan wrote:


On Thu, 10 Jan 2019, Hans Hagen wrote:


On 1/10/2019 10:26 PM, Aditya Mahajan wrote:

Hi,

I have an XML file (which is generated via a program that I have no 
control over), which contains elements as follows:


  
     
    height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>

     
  

I want to typeset the `text` attribute of equation (and ignore the  
tag). So, I tried:


\startxmlsetups matlab
   % Bunch of missing definitions
   \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:equation
   \xmlatt{#1}{text}
\stopxmlsetups

This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the 
attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for 
content and not attributes).

Time for an "aha, I knew it" moment ...


This contains `` which I want to convert to either newline or blank.


Some debugging showed that the entity was being translated correctly. I 
was typesetting the output under texcatcodes, which was causing the 
problem. Setting formfeedasciicode and endoflineasciicode to ignorecatcode 
made everything work correctly.


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] Setup typing indent next

2019-01-10 Thread Hans Åberg


> On 11 Jan 2019, at 00:13, Wolfgang Schuster 
>  wrote:
> 
> Hans Åberg schrieb am 10.01.19 um 22:52:
>>> On 10 Jan 2019, at 22:14, Wolfgang Schuster 
>>>  wrote:
>>> 
>>> Hans Åberg schrieb am 10.01.19 um 22:04:
 There seems to be no option for \setuptyping[indentnext=...] following the 
 TeX convention to indent new paragraphs, as followed by a blank row, but 
 not otherwise.
>>> 
>>> Are you looking for the auto option of the indentnext key?
>>> 
>>> \setupindenting[yes,medium]
>>> 
>>> \setuptyping[indentnext=auto]
>> Thanks! It is not listed at
>>   https://wiki.contextgarden.net/Command/setuptyping
> 
> Look into setup-en.pdf for a (nearly) complete list of all key/values.

It is there. Perhaps the web-pages might be autoupdated somehow from there.


___
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] XML and math

2019-01-10 Thread Aditya Mahajan

On Thu, 10 Jan 2019, Hans Hagen wrote:


On 1/10/2019 10:26 PM, Aditya Mahajan wrote:

Hi,

I have an XML file (which is generated via a program that I have no control 
over), which contains elements as follows:


  
     
    height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>

     
  

I want to typeset the `text` attribute of equation (and ignore the  
tag). So, I tried:


\startxmlsetups matlab
   % Bunch of missing definitions
   \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:equation
   \xmlatt{#1}{text}
\stopxmlsetups

This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the 
attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for 
content and not attributes).

Time for an "aha, I knew it" moment ...


:-) Thanks.

Follow-up question: How do I escape entities inside the attributes. One 
snippet is:


 
$$x_2(t) = 
\begin{cases}  t,  0 \leq t  5 \\ -t+10,   t \geq

5\end{cases}$$
 

This contains `` which I want to convert to either newline or blank.

(I have to use the text attribute. The content has the right information 
in this particular instance due to a bug in the conversion)


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] Setup typing indent next

2019-01-10 Thread Wolfgang Schuster

Hans Åberg schrieb am 10.01.19 um 22:52:




On 10 Jan 2019, at 22:14, Wolfgang Schuster  
wrote:

Hans Åberg schrieb am 10.01.19 um 22:04:

There seems to be no option for \setuptyping[indentnext=...] following the TeX 
convention to indent new paragraphs, as followed by a blank row, but not 
otherwise.


Are you looking for the auto option of the indentnext key?

\setupindenting[yes,medium]

\setuptyping[indentnext=auto]


Thanks! It is not listed at
   https://wiki.contextgarden.net/Command/setuptyping


Look into setup-en.pdf for a (nearly) complete list of all key/values.

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] XML and math

2019-01-10 Thread Aditya Mahajan

On Fri, 11 Jan 2019, Henri Menke wrote:


On 11/01/19 10:26 AM, Aditya Mahajan wrote:

Hi,

I have an XML file (which is generated via a program that I have no
control over), which contains elements as follows:

 
    
   
    
 

I want to typeset the `text` attribute of equation (and ignore the 
tag). So, I tried:

\startxmlsetups matlab
  % Bunch of missing definitions
  \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:equation
  \xmlatt{#1}{text}
\stopxmlsetups

This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the
attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for
content and not attributes).


You could write your own attribute fetcher in Lua.  Probably there is a
more elegant method.

\startbuffer[test]

   
  
   

\stopbuffer

\startxmlsetups matlab
 % Bunch of missing definitions
 \xmlsetsetup{#1}{p}{matlab:*}
 \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:p
 \xmlflush{#1}
\stopxmlsetups

\startxmlsetups matlab:equation
 \xmlfunction{#1}{equation}
\stopxmlsetups
\startluacode
local a = "text"
local ctxcatcodes = catcodes.numbers.ctxcatcodes

function xml.functions.equation(id)
   local e = lxml.getid(id)
   if e then
   local at = e.at
   if at then
   local att = at[a]
   if att ~= "" then
   context.sprint(ctxcatcodes,att)
   end
   end
   end
end
\stopluacode

\xmlregistersetup{matlab}

\starttext
\xmlprocessbuffer{test}{test}{}
\stoptext


Thanks!

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] XML and math

2019-01-10 Thread Hans Hagen

On 1/10/2019 10:26 PM, Aditya Mahajan wrote:

Hi,

I have an XML file (which is generated via a program that I have no 
control over), which contains elements as follows:


  
     
    height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>

     
  

I want to typeset the `text` attribute of equation (and ignore the  
tag). So, I tried:


\startxmlsetups matlab
   % Bunch of missing definitions
   \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:equation
   \xmlatt{#1}{text}
\stopxmlsetups

This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the 
attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for 
content and not attributes).

Time for an "aha, I knew it" moment ...

\starttext

\startbuffer[test]


   height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>



\stopbuffer

\startxmlsetups whatever
\xmlsetsetup{#1}{p|equation}{xml:*}
\stopxmlsetups

\xmlregistersetup{whatever}

\startxmlsetups xml:p
\xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:equation
\cldcontext{lxml.getid("#1").at.text}
\stopxmlsetups

\startxmlsetups xml:equation
\startformula
\cldcontext{(string.gsub(lxml.getid("#1").at.text,"[$][$]",""))}
\stopformula
\stopxmlsetups

\xmlprocessbuffer{main}{test}{}

\stoptext


-
  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] XML and math

2019-01-10 Thread Henri Menke
On 11/01/19 10:26 AM, Aditya Mahajan wrote:
> Hi,
> 
> I have an XML file (which is generated via a program that I have no
> control over), which contains elements as follows:
> 
>  
>     
>     height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>
>     
>  
> 
> I want to typeset the `text` attribute of equation (and ignore the 
> tag). So, I tried:
> 
> \startxmlsetups matlab
>   % Bunch of missing definitions
>   \xmlsetsetup{#1}{equation}{matlab:*}
> \stopxmlsetups
> 
> \startxmlsetups matlab:equation
>   \xmlatt{#1}{text}
> \stopxmlsetups
> 
> This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the
> attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for
> content and not attributes).

You could write your own attribute fetcher in Lua.  Probably there is a
more elegant method.

\startbuffer[test]
 

   

 
\stopbuffer

\startxmlsetups matlab
  % Bunch of missing definitions
  \xmlsetsetup{#1}{p}{matlab:*}
  \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:p
  \xmlflush{#1}
\stopxmlsetups

\startxmlsetups matlab:equation
  \xmlfunction{#1}{equation}
\stopxmlsetups
\startluacode
local a = "text"
local ctxcatcodes = catcodes.numbers.ctxcatcodes

function xml.functions.equation(id)
local e = lxml.getid(id)
if e then
local at = e.at
if at then
local att = at[a]
if att ~= "" then
context.sprint(ctxcatcodes,att)
end
end
end
end
\stopluacode

\xmlregistersetup{matlab}

\starttext
\xmlprocessbuffer{test}{test}{}
\stoptext


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

___
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] Setup typing indent next

2019-01-10 Thread Hans Åberg


> On 10 Jan 2019, at 22:14, Wolfgang Schuster 
>  wrote:
> 
> Hans Åberg schrieb am 10.01.19 um 22:04:
>> There seems to be no option for \setuptyping[indentnext=...] following the 
>> TeX convention to indent new paragraphs, as followed by a blank row, but not 
>> otherwise.
> 
> Are you looking for the auto option of the indentnext key?
> 
> \setupindenting[yes,medium]
> 
> \setuptyping[indentnext=auto]

Thanks! It is not listed at
  https://wiki.contextgarden.net/Command/setuptyping 


___
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] XML and math

2019-01-10 Thread Aditya Mahajan

Hi,

I have an XML file (which is generated via a program that I have no 
control over), which contains elements as follows:


 

   height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>


 

I want to typeset the `text` attribute of equation (and ignore the  
tag). So, I tried:


\startxmlsetups matlab
  % Bunch of missing definitions
  \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:equation
  \xmlatt{#1}{text}
\stopxmlsetups

This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the 
attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for 
content and not attributes).


Thanks,
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] Setup typing indent next

2019-01-10 Thread Wolfgang Schuster

Hans Åberg schrieb am 10.01.19 um 22:04:

There seems to be no option for \setuptyping[indentnext=...] following the TeX 
convention to indent new paragraphs, as followed by a blank row, but not 
otherwise.


Are you looking for the auto option of the indentnext key?

\setupindenting[yes,medium]

\setuptyping[indentnext=auto]

\starttext

\starttyping
Typing
\stoptyping
Paragraph

\starttyping
Typing
\stoptyping

Paragraph

\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] Setup typing indent next

2019-01-10 Thread Hans Åberg
There seems to be no option for \setuptyping[indentnext=...] following the TeX 
convention to indent new paragraphs, as followed by a blank row, but not 
otherwise.


___
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] fontloader error in latex: attempt to call upvalue 'getdirection' (a nil value)

2019-01-10 Thread Hans Hagen

On 1/10/2019 5:13 PM, Pablo Rodriguez wrote:


This was the same problem that prevented the compilation of the
following code:

 \setupdirections[bidi=on, method=two]
 \starttext
 \input zapf
 \stoptext

this is unlikely as you don't use generic ... probably another fix

(concerning your mails: gmx is kind of special i think ... i can never 
send mails that gmx adresses)


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] fontloader error in latex: attempt to call upvalue 'getdirection' (a nil value)

2019-01-10 Thread Pablo Rodriguez
On 1/7/19 12:40 AM, Ulrike Fischer wrote:
> I just tried to import the fontloader from 2019-01-03 into latex,
> and get on a simple document the error
> 
>  (./test-utf8.aux)error:
> ...ad/texmf/tex/luatex/luaotfload/fontloader-2019-01-03.lua:23868:
> attempt to call upvalue 'getdirection' (a nil value)
> [...]
> I have no idea (yet) if this is latex specific or if it could affect
> context too but thought I better mention it. The line refers to this
> part of the code:
> 
>   pardirstate=function(start)
> local nxt=getnext(start)
> local dir=getdirection(start) --<--
> if dir==lefttoright then
>   return nxt,1,1

Many thanks for your report, Ulrike.

This was the same problem that prevented the compilation of the
following code:

\setupdirections[bidi=on, method=two]
\starttext
\input zapf
\stoptext

After your report, Hans fixed the issue (which I tried to report twice,
but the mailing list rejected my messages).

Many thanks for your report and for the fix from Hans,

Pablo
-- 
http://www.ousia.tk
___
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] issue with backend.date

2019-01-10 Thread Pablo Rodriguez
Dear list,

I have the following sample:

\enabledirectives[backend.date=no]
\enabledirectives[backend.info=no]
\enabledirectives[backend.xmp=no]
\starttext
a
\stoptext

At least, backend.date doesn’t work with latest beta (2019.01.07 16:10)
as it used to work before.

I think this might be a bug.

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___
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] local ToC after each chapter title

2019-01-10 Thread Henning Hraban Ramm
Am 2019-01-10 um 15:21 schrieb Otared Kavian :

> Hi Hraban,
> 
> Probably instead of
> 
>> \setuplist[chapter][
>> before=,
>> after={\placecombinedlist[content][criterium=local]},]
> 
> you wanted to say
> 
> \setuphead[chapter][
>   before=,
>   after={\placecombinedlist[content][criterium=local]}]
> 
> which gives the expected result without any problem…

RGHLLL, I’m so blind...

Thank you, of course! That happens if you change an old, cluttered 
environment...

Sorry for the noise.

Greetlings, Hraban
---
https://www.fiee.net
http://wiki.contextgarden.net
https://www.dreiviertelhaus.de
GPG Key ID 1C9B22FD

___
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] final thoughts on experiments with lua

2019-01-10 Thread luigi scarso
On Thu, Jan 10, 2019 at 12:11 PM Henning Hraban Ramm  wrote:

>
>  a Lua pairs table, the order can be arbitrary.
>

sure ,  the *default*  __pairs gives pseudo-arbitrary order, but you can
always use metatable:
--
-- test.lua
--
local _c,_t=0,{}
local t = {}
setmetatable(t, {
   __newindex = function(tbl, k, v)
  _c=_c+1
  _t[_c]=k
  rawset(tbl, k, v)
   end,

  __pairs = function(tbl)
  local i = 1
  return function(tbl,k)
k = _t[i]
i=i+1
return k,tbl[k]
  end, tbl,nil
end,
})


t['a']= 'aaa'
t['3a']= '3aa'
t['b']= 'baa'
t['2b']= '2ba'
t['c']= 'caa'
t['2c']= '2ca'
t['d']= 'daa'
t['2d']= '2da'
t['e']= 'eaa'
t['2e']= '2ea'


for k,v in pairs(t) do print(k,v) end



$ mtxrun --script test.lua
a aaa
3a 3aa
b baa
2b 2ba
c caa
2c 2ca
d daa
2d 2da
e eaa
2e 2ea

--
luigi
___
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] local ToC after each chapter title

2019-01-10 Thread Otared Kavian
Hi Hraban,

Probably instead of

> \setuplist[chapter][
>  before=,
>  after={\placecombinedlist[content][criterium=local]},]

you wanted to say

\setuphead[chapter][
before=,
after={\placecombinedlist[content][criterium=local]}]

which gives the expected result without any problem…

Best regards: OK

> On 10 Jan 2019, at 14:34, Henning Hraban Ramm  wrote:
> 
> Hello again,
> 
> in my current book project I need a local ToC after each chapter title.
> What’s wrong with my use of "after"?
> 
> The following example leads to a "TeX capacity exceeded" error:
> 
> \setupcombinedlist[content][%
>  list={chapter,section},]
> 
> \setuplist[chapter][
>  before=,
>  after={\placecombinedlist[content][criterium=local]},]
> 
> \starttext
> 
> \completecontent
> 
> \chapter{One}
> 
> \section{Knuth}
> \input knuth
> 
> \section{Tufte}
> \input tufte
> 
> \chapter{Two}
> 
> \section{Tufte 2}
> \input tufte
> 
> \chapter{Three}
> 
> \section{Zapf}
> \input zapf
> 
> \stoptext
> 
> (MkIV, version 2018.12.19 19:22)
> 
> 
> Greetlings, Hraban
> ---
> https://www.fiee.net
> http://wiki.contextgarden.net
> https://www.dreiviertelhaus.de
> GPG Key ID 1C9B22FD
> 
> ___
> 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] local ToC after each chapter title

2019-01-10 Thread Henning Hraban Ramm
Hello again,

in my current book project I need a local ToC after each chapter title.
What’s wrong with my use of "after"?

The following example leads to a "TeX capacity exceeded" error:

\setupcombinedlist[content][%
  list={chapter,section},]

\setuplist[chapter][
  before=,
  after={\placecombinedlist[content][criterium=local]},]

\starttext

\completecontent

\chapter{One}

\section{Knuth}
\input knuth

\section{Tufte}
\input tufte

\chapter{Two}

\section{Tufte 2}
\input tufte

\chapter{Three}

\section{Zapf}
\input zapf

\stoptext

(MkIV, version 2018.12.19 19:22)


Greetlings, Hraban
---
https://www.fiee.net
http://wiki.contextgarden.net
https://www.dreiviertelhaus.de
GPG Key ID 1C9B22FD

___
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] final thoughts on experiments with lua

2019-01-10 Thread Hans Hagen

On 1/10/2019 12:11 PM, Henning Hraban Ramm wrote:

Am 2019-01-10 um 10:50 schrieb luigi scarso :


sections = { “1”, “2”, “2a” }

words = { [“1”] = { “a”, “b” },
   [“2a”] = { “c”, “d” } }

so I can iterate through ipairs(sections) in sequence and pick up the word 
lists for each section. In the greater scheme of things, as Hraban pointed out: 
if there were an “ordered table” structure in Lua, this is precisely what it 
would do behind the scenes; it would just make it easier for the user.


the point is that I believe that is also doable in lua...
maybe could be helpful to have a significative example in python, ton see if we 
can mimic it in lua  ?


The "minimal example" in Python is a collections.OrderedDict. It’s not about 
ordering the entries (anew), but keeping the order, i.e. retrieving the entries in the 
same order as you added them. If you iterate over a Python dict or a Lua pairs table, the 
order can be arbitrary.


I'll add this:

local t = table.orderedhash()

t["1"]  = { "a", "b" }
t["2"]  = { }
t["2a"] = { "a", "c", "d" }

for k, v in table.ordered(t) do
print(k)
inspect(v)
end

which gives

1
table={
 "a",
 "b",
}
2
table={
}
3
table={
 "a",
 "c",
 "d",
}



-
  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] final thoughts on experiments with lua

2019-01-10 Thread Henning Hraban Ramm
Am 2019-01-10 um 10:50 schrieb luigi scarso :

>> sections = { “1”, “2”, “2a” }
>> 
>> words = { [“1”] = { “a”, “b” },
>>   [“2a”] = { “c”, “d” } }
>> 
>> so I can iterate through ipairs(sections) in sequence and pick up the word 
>> lists for each section. In the greater scheme of things, as Hraban pointed 
>> out: if there were an “ordered table” structure in Lua, this is precisely 
>> what it would do behind the scenes; it would just make it easier for the 
>> user.
>> 
> the point is that I believe that is also doable in lua...
> maybe could be helpful to have a significative example in python, ton see if 
> we can mimic it in lua  ?

The "minimal example" in Python is a collections.OrderedDict. It’s not about 
ordering the entries (anew), but keeping the order, i.e. retrieving the entries 
in the same order as you added them. If you iterate over a Python dict or a Lua 
pairs table, the order can be arbitrary.

Greetlings, Hraban
---
https://www.fiee.net
http://wiki.contextgarden.net
https://www.dreiviertelhaus.de
GPG Key ID 1C9B22FD

___
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] final thoughts on experiments with lua

2019-01-10 Thread luigi scarso
On Thu, Jan 10, 2019 at 10:27 AM Schmitz Thomas A. <
thomas.schm...@uni-bonn.de> wrote:

>
>
> > On 10. Jan 2019, at 01:08, Hans Hagen  wrote:
> >
> > it all depends on use ... if you can be more specific ...
>
> Hans, Luigi,
>
> thanks for your hints on list sorting - they are appreciated, but I’ve
> been there many many times: it’s impossible to be more specific because
> numbering can be unexpectedly weird. Combinations of Greek and Roman
> letters, sometimes (for historic reasons) even lines that are out of
> numeric sequence. I’ve tried to catch these exceptions in sort functions,
> only to have to add even more ifs and buts when I was processing the next
> author. And I’m pretty sure that the solution is not in sorting a table
> index: the correct sequence is already in the source, it just has to be
> preserved. What I do now, in a nutshell: I have tables such as
>
> sections = { “1”, “2”, “2a” }
>
> words = { [“1”] = { “a”, “b” },
>   [“2a”] = { “c”, “d” } }
>
> so I can iterate through ipairs(sections) in sequence and pick up the word
> lists for each section. In the greater scheme of things, as Hraban pointed
> out: if there were an “ordered table” structure in Lua, this is precisely
> what it would do behind the scenes; it would just make it easier for the
> user.
>

the point is that I believe that is also doable in lua...
maybe could be helpful to have a significative example in python, ton see
if we can mimic it in lua  ?

-- 
luigi
___
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] final thoughts on experiments with lua

2019-01-10 Thread Schmitz Thomas A.


> On 10. Jan 2019, at 01:08, Hans Hagen  wrote:
> 
> it all depends on use ... if you can be more specific ...

Hans, Luigi,

thanks for your hints on list sorting - they are appreciated, but I’ve been 
there many many times: it’s impossible to be more specific because numbering 
can be unexpectedly weird. Combinations of Greek and Roman letters, sometimes 
(for historic reasons) even lines that are out of numeric sequence. I’ve tried 
to catch these exceptions in sort functions, only to have to add even more ifs 
and buts when I was processing the next author. And I’m pretty sure that the 
solution is not in sorting a table index: the correct sequence is already in 
the source, it just has to be preserved. What I do now, in a nutshell: I have 
tables such as

sections = { “1”, “2”, “2a” }

words = { [“1”] = { “a”, “b” },
  [“2a”] = { “c”, “d” } }

so I can iterate through ipairs(sections) in sequence and pick up the word 
lists for each section. In the greater scheme of things, as Hraban pointed out: 
if there were an “ordered table” structure in Lua, this is precisely what it 
would do behind the scenes; it would just make it easier for the user.

Best

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
___