Re: [NTG-context] New module: simplesteps.
Thank you both, Philipp and Wolfgang, I've updated the wiki. Wolfgang wrote: > You have to give the name of begin command because context has to know it > when buffers > are nested (I will a explanation about this in another thread). Ah, I was wondering about that. Yes, I'd be interested in the background explanation. Cheers, Sietse On Sat, Dec 15, 2012 at 1:38 PM, Wolfgang Schuster wrote: > > Am 15.12.2012 um 11:28 schrieb Sietse Brouwer : > \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } >>> >>> With the \grabbufferdata command the content beginning from \startframe >>> until \stopframe is stored in a buffer with the name “simplesteps”. >> >> (1) What does the \begingroup do? I could not find a \endgroup in the >> patch, nor in the module code. >> >> (2) I've approximately documented grabbufferdata here: >> http://wiki.contextgarden.net/Command/grabbufferdata >> But when I tried to write a minimal example, I couldn't get it to compile. >> >> %% begin example >> \grabbufferdata[mybuffer][thisisthestart][thisistheend] >> \thisisthestart >> My friend, you would not tell with such high zest >> To children ardent for some desparate glory, >> The old Lie: Dulce et decorum est >> Pro patria mori. >> \thisistheend >> >> \typebuffer[mybuffer] >> %% end example >> >> What am I doing wrong? And is the description I put on the wiki correct? > > > The \grabbufferdata command reads only all text until the end command (e.g. > \thisistheend) > but the beginning command for the buffer (e.g. thisisthestart) has to be > defined by the user. > > You have to give the name of begin command because context has to know it > when buffers > are nested (I will a explanation about this in another thread). > > \starttext > > \def\thisisthestart > {\grabbufferdata[mybuffer][thisisthestart][thisistheend]} > > \thisisthestart > My friend, you would not tell with such high zest > To children ardent for some desparate glory, > The old Lie: Dulce et decorum est > Pro patria mori. > \thisistheend > > \typebuffer[mybuffer] > > \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://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Am 15.12.2012 um 11:28 schrieb Sietse Brouwer : >>> \begingroup >>> \grabbufferdata[simplesteps][startframe][stopframe]% >>> } >> >> With the \grabbufferdata command the content beginning from \startframe >> until \stopframe is stored in a buffer with the name “simplesteps”. > > (1) What does the \begingroup do? I could not find a \endgroup in the > patch, nor in the module code. > > (2) I've approximately documented grabbufferdata here: > http://wiki.contextgarden.net/Command/grabbufferdata > But when I tried to write a minimal example, I couldn't get it to compile. > > %% begin example > \grabbufferdata[mybuffer][thisisthestart][thisistheend] > \thisisthestart > My friend, you would not tell with such high zest > To children ardent for some desparate glory, > The old Lie: Dulce et decorum est > Pro patria mori. > \thisistheend > > \typebuffer[mybuffer] > %% end example > > What am I doing wrong? And is the description I put on the wiki correct? The \grabbufferdata command reads only all text until the end command (e.g. \thisistheend) but the beginning command for the buffer (e.g. thisisthestart) has to be defined by the user. You have to give the name of begin command because context has to know it when buffers are nested (I will a explanation about this in another thread). \starttext \def\thisisthestart {\grabbufferdata[mybuffer][thisisthestart][thisistheend]} \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] \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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
· > > Am 15.12.2012 um 11:40 schrieb Philipp Gesang > : > > > · > > > \begingroup > \grabbufferdata[simplesteps][startframe][stopframe]% > } > >>> > >>> With the \grabbufferdata command the content beginning from \startframe > >>> until \stopframe is stored in a buffer with the name “simplesteps”. > >> > >> (1) What does the \begingroup do? I could not find a \endgroup in the > >> patch, nor in the module code. > > > > It’s in the definition of \buff_stop in buff-ini.mkiv. The first > > thing \startbuffer does is to insert a bgroup, too. > > The \begingroup shouldn’t be here because the buffer code does end all groups > it opens > and the extra group you open is never closed. Argh, yes of course, there it is: “\end occurred inside group.” Tracing back I think it’s a leftover. Thanks for checking! Philipp pgppzwwU1GXt2.pgp Description: PGP signature ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Am 15.12.2012 um 11:40 schrieb Philipp Gesang : > · > \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } >>> >>> With the \grabbufferdata command the content beginning from \startframe >>> until \stopframe is stored in a buffer with the name “simplesteps”. >> >> (1) What does the \begingroup do? I could not find a \endgroup in the >> patch, nor in the module code. > > It’s in the definition of \buff_stop in buff-ini.mkiv. The first > thing \startbuffer does is to insert a bgroup, too. The \begingroup shouldn’t be here because the buffer code does end all groups it opens and the extra group you open is never closed. 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Am 15.12.2012 um 12:49 schrieb Hans Hagen : > (dangerous name: \startframe ... could be core name) It depends, using it asa global name isa no go but defining it inside group is useful, e.g. \def\mycommand_start {\begingroup \let\startframe\mycommand_frame_start \let\stopframe \mycommand_frame_stop} \def\mycommand_Stop {\endgroup} 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
On 12/15/2012 7:02 AM, Wolfgang Schuster wrote: Am 15.12.2012 um 00:07 schrieb Andre Caldas : thanks for the interesting contribution! Have a look at the patch I hopefully don’t forget to append. I didn't quite understood how this works: \unexpanded\def\startframe{\dosingleempty\frame_start} This creates the new command \startframe which calls the internal command \frame_start which has one optional argument. \def\frame_start[#1]{% \iffirstargument \section{#1}%% solution needed here! \fi This block checks if the optional argument is used by the user, when the argument is used the content is typeset as \section. \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. \let\stopframe\simplestepsplaybuffer This makes the \stopframe command a synonym for \simplestepsplaybuffer which is now called when the frame environment ends. best use a namespace: \simplesteps_start_frame (dangerous name: \startframe ... could be core name) Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
On 2012–12–15 Sietse Brouwer wrote: > But when I tried to write a minimal example, I couldn't get it to compile. > > %% begin example > \grabbufferdata[mybuffer][thisisthestart][thisistheend] > \thisisthestart > My friend, you would not tell with such high zest > To children ardent for some desparate glory, > The old Lie: Dulce et decorum est > Pro patria mori. > \thisistheend > > \typebuffer[mybuffer] > %% end example > > What am I doing wrong? You have to wrap it in a macro: \starttext \define\thisisthestart {\grabbufferdata[mybuffer][thisisthestart][thisistheend]} \let\thisistheend\relax %% not necessary \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] \stoptext Marco signature.asc Description: Digital signature ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
> %% begin example > \grabbufferdata[mybuffer][thisisthestart][thisistheend] > \thisisthestart > My friend, you would not tell with such high zest > To children ardent for some desparate glory, > The old Lie: Dulce et decorum est > Pro patria mori. > \thisistheend > > \typebuffer[mybuffer] > %% end example > > What am I doing wrong? And is the description I put on the wiki correct? It's just a guess... but I think the \grabbufferdata has to be invoked *after* the \thisisthestart, \thisistheend pair. André Caldas. ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
· > >> \begingroup > >> \grabbufferdata[simplesteps][startframe][stopframe]% > >> } > > > > With the \grabbufferdata command the content beginning from \startframe > > until \stopframe is stored in a buffer with the name “simplesteps”. > > (1) What does the \begingroup do? I could not find a \endgroup in the > patch, nor in the module code. It’s in the definition of \buff_stop in buff-ini.mkiv. The first thing \startbuffer does is to insert a bgroup, too. Philipp pgpeFsXMBI40v.pgp Description: PGP signature ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
>> \begingroup >> \grabbufferdata[simplesteps][startframe][stopframe]% >> } > > With the \grabbufferdata command the content beginning from \startframe until > \stopframe is stored in a buffer with the name “simplesteps”. (1) What does the \begingroup do? I could not find a \endgroup in the patch, nor in the module code. (2) I've approximately documented grabbufferdata here: http://wiki.contextgarden.net/Command/grabbufferdata But when I tried to write a minimal example, I couldn't get it to compile. %% begin example \grabbufferdata[mybuffer][thisisthestart][thisistheend] \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] %% end example What am I doing wrong? And is the description I put on the wiki correct? Cheers, Sietse ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Am 15.12.2012 um 00:07 schrieb Andre Caldas : >> thanks for the interesting contribution! Have a look at the patch >> I hopefully don’t forget to append. > > I didn't quite understood how this works: > \unexpanded\def\startframe{\dosingleempty\frame_start} This creates the new command \startframe which calls the internal command \frame_start which has one optional argument. > \def\frame_start[#1]{% > \iffirstargument >\section{#1}%% solution needed here! > \fi This block checks if the optional argument is used by the user, when the argument is used the content is typeset as \section. > \begingroup > \grabbufferdata[simplesteps][startframe][stopframe]% > } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. > \let\stopframe\simplestepsplaybuffer This makes the \stopframe command a synonym for \simplestepsplaybuffer which is now called when the frame environment ends. 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
> thanks for the interesting contribution! Have a look at the patch > I hopefully don’t forget to append. I didn't quite understood how this works: \unexpanded\def\startframe{\dosingleempty\frame_start} \def\frame_start[#1]{% \iffirstargument \section{#1}%% solution needed here! \fi \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } \let\stopframe\simplestepsplaybuffer Cheers, André Caldas. ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Hello, OK! > You were so quick to write your module… > Thanks for sharing, :-) > but I could not typeset the example file you sent: > I didn't get whether your file simplesteps.mkiv should be renamed I did this on my machine: 1. Copy simplesteps.{lua,mkiv} to texmf-local/tex/context/third/simplesteps/ In my case, it is here: /home/andre/context_standalone/tex/texmf-local/tex/context/third/simplesteps 2. Clear the cache. I don't really know the proper way to do that. So, I just removed the directory texmf-cache. In my case: rm /home/andre/context_standalone/tex/texmf-cache/ -rf 3. Compile: context simpletest.tex > Maybe after you apply the changes suggested > by Wolfgang and Philip you are going to repost your moudle? The module will be here: https://bitbucket.org/andrecaldas/context-simplesteps Hopefully, one day, here... ;-) http://modules.contextgarden.net/ I will let you know. Cheers, André Caldas. ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Hi André, You were so quick to write your module… Thanks for sharing, but I could not typeset the example file you sent: I didn't get whether your file simplesteps.mkiv should be renamed simplesteps.mkiv or simplesteps.tex or even t-simplesteps.tex or any other suffix. Maybe after you apply the changes suggested by Wolfgang and Philip you are going to repost your moudle? Best regards: OK On 14 déc. 2012, at 12:21, Andre Caldas wrote: > Hello! > >> thanks for the interesting contribution! Have a look at the patch >> I hopefully don’t forget to append. > > Thank you! I will take a look and learn... ;-) > > >>> [...] >>> I use \startbuffer and \stopbuffer, and also Lua. As I said, I don't >>> really know how to write a module... comments are very welcome. >> >> Honestly, it doesn’t work, but that’s a minor flaw! > > Sorry! I forgot to mention. Only a little subset of it works. I have > (already - so I don't forget to) attached a "tex" file that works. > > >> [**lots of advices I will study carefully latter**] >> [...] >> I could not figure out how exactly the section block thingy is >> supposed to work. It does not create the \startframe macro at all >> -- is this something custom? > > I don't know how to use this "startframe" yet. So, I am doing like > this right now: (numbers like 2-3 or 2- don't work yet) > > === START code snip === > \startbuffer[simplesteps] > \startitemize >\item First item >\uncover[2,3,4]{\item Second item} >\uncover[3,4]{\item Second item} >\uncover[4]{\item Second item} > \stopitemize > \stopbuffer > \simplestepsplaybuffer > === STOP code snip === > > The "simplestepsplaybuffer" macro simply calls the > simplesteps.playbuffer() lua function. This function plays the buffer > and determines if it has to be played again or not. If it does, then > it tex.print('\simplestepsplaybuffer'). > > The macros "uncover" determine how far the specification is from being > played. If it is being played now, then show. If it is played "next", > then show in gray. And so on. > > >> I infer it’s about the slide title >> so I have \startframe call \section but that should be taken as a >> placeholder at most. In my own slide module I use >> \{start,stop}section with the option placehead=no and rely on the >> page header to display the slide title (i.e. current section >> running head). That was the laziest way I could imagine :P > > I guess that's what I want to do. I just don't have the necessary > knowledge yet. ;-) > > >> Some remarks: >> >> - you should rename simplesteps.mkiv to t-simplesteps.mkiv, >>indicating that it is a thirdparty module > > I will. I think I will have a bitbucket repository exclusively for > modules. Then I will have the proper directory structure, the proper > naming scheme and hopefully proper documentation, xml, etc. (lots of > things to learn!) > > >> - if you plan on expanding the code you eventually will come to >>love this bit: http://wiki.contextgarden.net/System_Macros >> - Context has a namespacing system which you might consider >>switching to in the long term: >> http://tex.stackexchange.com/q/58654 >>but it’s arguably an advanced method > > Well, I do want to do it the right (recommended) way! > > >> - maybe switch to mkvi as named parameters make rewriting >>macros a breeze > > Would you elaborate a bit further? > > >>> Is it ok if I send a PDF sample to the list? > > I hope you can use the TEX file attached. > > > Cheers, > André Caldas. > ___ > 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://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
> These expand to Lua long strings, [===[ and ]===] respectively, > without checking, so theoretically the same issue will arise iff > your string contains ]===]. I consider the likelihood for this to > happen to be too low to bother, but if you want to be absolutely > on the safe side you can also use \luaescapestring. See the > Luatex manual, section 2.3.6. The luaescapestring will also escape the quotation marks... :-) I will use it, then. I used to develop WEB systems. Very vulnerable to injection attacks. I really like things properly escaped... Cheers, André Caldas. ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
· > > \unexpanded\def\uncover[#1]% > > {\ctxlua{ > > distance = simplesteps.distance_to_step(\!!bs#1\!!es) > > ... > > }} > > > > it works because the " is now only part of the string. > > Thanks. That's what I needed. I guess > bs = begin string > es = end string. These expand to Lua long strings, [===[ and ]===] respectively, without checking, so theoretically the same issue will arise iff your string contains ]===]. I consider the likelihood for this to happen to be too low to bother, but if you want to be absolutely on the safe side you can also use \luaescapestring. See the Luatex manual, section 2.3.6. Philipp pgp9lYpucmZ36.pgp Description: PGP signature ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
> \unexpanded\def\uncover[#1]% > {\ctxlua{ > distance = simplesteps.distance_to_step(\!!bs#1\!!es) > ... > }} > > it works because the " is now only part of the string. Thanks. That's what I needed. I guess bs = begin string es = end string. Cheers, André Caldas. ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Am 14.12.2012 um 17:18 schrieb Andre Caldas : >>> I have one question: >>> - What does it happen when there is a quotation mark (") inside the >>> parameter? Do I need to "escape" the contents passed to the macro? >> >> >> No you don’t have to but you could have checked yourself :) > > Sorry... I didn't try it when I asked, but I had the impression I did > try it before. In my case, if I use > \uncover[2,"3]{} > I get the error: =P > ! LuaTeX error :1: ')' expected near '3'. You’re trying to pass a single " to Lua which doesn’t work because you use "" in your Lua code for the string. When you change your definition for \uncover to \unexpanded\def\uncover[#1]% {\ctxlua{ distance = simplesteps.distance_to_step(\!!bs#1\!!es) ... }} it works because the " is now only part of the string. 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
>> I have one question: >> - What does it happen when there is a quotation mark (") inside the >> parameter? Do I need to "escape" the contents passed to the macro? > > > No you don’t have to but you could have checked yourself :) Sorry... I didn't try it when I asked, but I had the impression I did try it before. In my case, if I use \uncover[2,"3]{} I get the error: =P ! LuaTeX error :1: ')' expected near '3'. system > tex > error on line 6 in file virtual://buffer.simplesteps.5: LuaTeX error ... \uncover ...t('\\simplestepscoveredveryfar') end } l.6 \uncover[2,"3] {\item The {\em second main message} of your talk in o... ? Cheers, André Caldas. ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Am 14.12.2012 um 16:43 schrieb Andre Caldas : - maybe switch to mkvi as named parameters make rewriting macros a breeze >>> >>> Would you elaborate a bit further? >> >> You can use for the parameter in your macros names instead of number, >> as you can see below the first definition uses “#1” for the argument while >> the second uses “#text”. >> >> You can force MkIV mode when you add “% macros=mkvi” at the top >> of the file. When your code is a external file (e.g. a module) you can >> give it “mkvi” as file extension (instead of the normal “tex” or “mkiv”) >> and don’t need this line anymore. > > I had tried named parameters and I didn't know why it was not > working... now I know! :-) The file extension/first line is necessary because TeX itself still expects numbered parameters and context has to convert the names to numbers before TeX sees them. To know when such a conversion is necessary the file extension is a hint for context. > I have one question: > - What does it happen when there is a quotation mark (") inside the > parameter? Do I need to "escape" the contents passed to the macro? No you don’t have to but you could have checked yourself :) \starttext \bold{"} \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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
>>> - maybe switch to mkvi as named parameters make rewriting >>>macros a breeze >> >> Would you elaborate a bit further? > > You can use for the parameter in your macros names instead of number, > as you can see below the first definition uses “#1” for the argument while > the second uses “#text”. > > You can force MkIV mode when you add “% macros=mkvi” at the top > of the file. When your code is a external file (e.g. a module) you can > give it “mkvi” as file extension (instead of the normal “tex” or “mkiv”) > and don’t need this line anymore. I had tried named parameters and I didn't know why it was not working... now I know! :-) I have one question: - What does it happen when there is a quotation mark (") inside the parameter? Do I need to "escape" the contents passed to the macro? André Caldas. ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Am 14.12.2012 um 12:21 schrieb Andre Caldas : >> - maybe switch to mkvi as named parameters make rewriting >>macros a breeze > > Would you elaborate a bit further? You can use for the parameter in your macros names instead of number, as you can see below the first definition uses “#1” for the argument while the second uses “#text”. You can force MkIV mode when you add “% macros=mkvi” at the top of the file. When your code is a external file (e.g. a module) you can give it “mkvi” as file extension (instead of the normal “tex” or “mkiv”) and don’t need this line anymore. begin example % macros=mkvi \def\mkivhighlight#1{{\red #1}} \def\mkvihighlight#text{{\green #text}} \starttext \mkivhighlight{MkIV} \mkvihighlight{MkVI} \stoptext end example 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Hello! > thanks for the interesting contribution! Have a look at the patch > I hopefully don’t forget to append. Thank you! I will take a look and learn... ;-) >> [...] >> I use \startbuffer and \stopbuffer, and also Lua. As I said, I don't >> really know how to write a module... comments are very welcome. > > Honestly, it doesn’t work, but that’s a minor flaw! Sorry! I forgot to mention. Only a little subset of it works. I have (already - so I don't forget to) attached a "tex" file that works. > [**lots of advices I will study carefully latter**] > [...] > I could not figure out how exactly the section block thingy is > supposed to work. It does not create the \startframe macro at all > -- is this something custom? I don't know how to use this "startframe" yet. So, I am doing like this right now: (numbers like 2-3 or 2- don't work yet) === START code snip === \startbuffer[simplesteps] \startitemize \item First item \uncover[2,3,4]{\item Second item} \uncover[3,4]{\item Second item} \uncover[4]{\item Second item} \stopitemize \stopbuffer \simplestepsplaybuffer === STOP code snip === The "simplestepsplaybuffer" macro simply calls the simplesteps.playbuffer() lua function. This function plays the buffer and determines if it has to be played again or not. If it does, then it tex.print('\simplestepsplaybuffer'). The macros "uncover" determine how far the specification is from being played. If it is being played now, then show. If it is played "next", then show in gray. And so on. > I infer it’s about the slide title > so I have \startframe call \section but that should be taken as a > placeholder at most. In my own slide module I use > \{start,stop}section with the option placehead=no and rely on the > page header to display the slide title (i.e. current section > running head). That was the laziest way I could imagine :P I guess that's what I want to do. I just don't have the necessary knowledge yet. ;-) > Some remarks: > > - you should rename simplesteps.mkiv to t-simplesteps.mkiv, > indicating that it is a thirdparty module I will. I think I will have a bitbucket repository exclusively for modules. Then I will have the proper directory structure, the proper naming scheme and hopefully proper documentation, xml, etc. (lots of things to learn!) > - if you plan on expanding the code you eventually will come to > love this bit: http://wiki.contextgarden.net/System_Macros > - Context has a namespacing system which you might consider > switching to in the long term: > http://tex.stackexchange.com/q/58654 > but it’s arguably an advanced method Well, I do want to do it the right (recommended) way! > - maybe switch to mkvi as named parameters make rewriting > macros a breeze Would you elaborate a bit further? >> Is it ok if I send a PDF sample to the list? I hope you can use the TEX file attached. Cheers, André Caldas. simpletest.tex Description: TeX document ___ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Hey André, thanks for the interesting contribution! Have a look at the patch I hopefully don’t forget to append. · > Well since Raw Steps did not work with mkiv, I tried making a very > very simple module for a "beamer-like" behaviour. > > I don't really know how to write a module... but here is what I did: > https://bitbucket.org/andrecaldas/math-video-classes/src/9116599821fc246cb54d3e6d7b8e6304649eaffb/lib?at=default > > I use \startbuffer and \stopbuffer, and also Lua. As I said, I don't > really know how to write a module... comments are very welcome. Honestly, it doesn’t work, but that’s a minor flaw! If you want to use buffers with indirection you have to take care of the argument delimiters. \grabbufferdata is excellent for that. I did some rewriting: stray globals and rough namespacing, mostly. On the practice of calling TeX macros from Lua, the cld manual can give you a boost: http://www.pragma-ade.com/general/manuals/cld-mkiv.pdf This explains how to properly use the context.*() namespace instead of tex.print and the likes. I could not figure out how exactly the section block thingy is supposed to work. It does not create the \startframe macro at all -- is this something custom? I infer it’s about the slide title so I have \startframe call \section but that should be taken as a placeholder at most. In my own slide module I use \{start,stop}section with the option placehead=no and rely on the page header to display the slide title (i.e. current section running head). That was the laziest way I could imagine :P Some remarks: - you should rename simplesteps.mkiv to t-simplesteps.mkiv, indicating that it is a thirdparty module - if you plan on expanding the code you eventually will come to love this bit: http://wiki.contextgarden.net/System_Macros - Context has a namespacing system which you might consider switching to in the long term: http://tex.stackexchange.com/q/58654 but it’s arguably an advanced method - maybe switch to mkvi as named parameters make rewriting macros a breeze > Is it ok if I send a PDF sample to the list? For uploading docs and such to the “downloads” section on bitbucket is great. Then just post a link. Happy TeXing! Philipp diff -r 9116599821fc lib/simplesteps.lua --- a/lib/simplesteps.lua Thu Dec 13 20:49:38 2012 -0200 +++ b/lib/simplesteps.lua Fri Dec 14 01:59:00 2012 +0100 @@ -7,10 +7,12 @@ license = "GPL version 3.0 or any later version" } -simplesteps = simplesteps or {} +thirddata = thirddata or {} +thirddata.simplesteps = thirddata.simplesteps or {} +local simplesteps = thirddata.simplesteps -local stepcounter = 0 -local maxstepcount = 1 +local stepcounter = 0 +local maxstepcount = 1 function simplesteps.distance_to_step(str) @@ -51,7 +53,7 @@ function simplesteps.update_maxstepcount(steps) for i=1,#steps do -step = steps[i] +local step = steps[i] if maxstepcount < step then maxstepcount = step diff -r 9116599821fc lib/simplesteps.mkiv --- a/lib/simplesteps.mkiv Thu Dec 13 20:49:38 2012 -0200 +++ b/lib/simplesteps.mkiv Fri Dec 14 01:59:00 2012 +0100 @@ -18,7 +18,7 @@ \unprotect %D \macros -%D {simplesteps} +%D {startframe,stopframe} %D %D \startframe[Slide 1] %D \startitemize @@ -31,49 +31,53 @@ \unexpanded\def\uncover[#1]% {\ctxlua{ - distance = simplesteps.distance_to_step("#1") + local distance = thirddata.simplesteps.distance_to_step("#1") if 0 == distance then elseif 1 == distance then -tex.sprint('\\simplestepscoverednext') +context.simplestepscoverednext() elseif 2 == distance then -tex.sprint('\\simplestepscoveredfar') +context.simplestepscoveredfar() else -tex.sprint('\\simplestepscoveredveryfar') +context.simplestepscoveredveryfar() end }} \unexpanded\def\only[#1]% {\ctxlua{ - if not simplesteps.instep("#1") + if not thirddata.simplesteps.instep("#1") then -tex.sprint('\\simplestepshidden') +context.simplestepshidden() end }} \unexpanded\def\simplestepsplaybuffer% - {\ctxlua{simplesteps.playbuffer()}} + {\ctxlua{thirddata.simplesteps.playbuffer()}} -\definecolor[hidden1][s=0.75] -\definecolor[hidden2][s=0.90] -\definecolor[hidden3][s=0.95] +\definecolor[simplesteps:hidden1][s=0.75] +\definecolor[simplesteps:hidden2][s=0.90] +\definecolor[simplesteps:hidden3][s=0.95] \unexpanded\def\simplestepshidden#1{} -\unexpanded\def\simplestepscoverednext#1{\color[hidden1]{#1}} -\unexpanded\def\simplestepscoveredfar#1{\color[hidden2]{#1}} -\unexpanded\def\simplestepscoveredveryfar#1{\color[hidden3]{#1}} +\unexpanded\def\simplestepscoverednext#1{\color[simplesteps:hidden1]{#1}} +\unexpanded\def\simplestepscoveredfar#1{\color[simplesteps:hidden2]{#1}} +\unexpanded\def\simplestepscoveredveryfar#1{\color[simplesteps:hidden3]{#1