Re: [NTG-context] Grammar to parse TeX input?

2018-11-28 Thread Hans Hagen

On 11/28/2018 9:33 AM, Joseph Canedo wrote:
I’d like to change some input to modify used font but only in parts of 
it, for example to implement having first line with different font. So 
basically if I have text with macros etc…:

% firstlines-001.tex

\setupbodyfont
  [pagella]

\setupalign
  [tolerant,stretch]

\setupfirstline
  [alternative=line,
   color=darkred,
   style=\setfontfeature{smallcaps}]

\setupfirstline
  [fancy]
  [n=3]

\setupfirstline
  [fancier]
  [alternative=word,
   color=darkblue,
   style=bold,
   n=3]

\setupfirstline
  [weirder]
  [alternative=line,
   color=darkgreen,
   style=\setfontfeature{smallcaps},
   n=3]

\setupinitial
  [location=text,
   n=2,
   color=darkred,
   voffset=1.2\lineheight,
   before={\blank[2*big]}]

% \enabletrackers[typesetters.firstlines,typesetters.initials]

\starttext

\setfirstline

\input ward \par

\placeinitial

\input ward \par

\setupindenting[medium,yes]

\setinitial % \placeinitial

\input ward \par

\setinitial %  \placeinitial
\setfirstline

\input ward \par

\setfirstline[fancy]

\input ward \par

\setfirstline[fancier]

\input ward \par

\setinitial %  \placeinitial
\setfirstline[weirder]

\input ward \par

\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] Grammar to parse TeX input?

2018-11-28 Thread Joseph Canedo
I’d like to change some input to modify used font but only in parts of it, for 
example to implement having first line with different font. So basically if I 
have text with macros etc…:

\WORD{i}eu \Note[]{}{Ebrieux \LeftDot 11.a.}crea au commencement le ciel et la 
terre. Et la terre
estoit \Note[]{*}{{\Hebreu\Tav\He\Vav} c'est a dire/ vaine/ qui ne proffite et 
ne sert a rien.}indisposee et \Note[]{*}{{\Hebreu\Bet\He\Vav} non remplie & 
ornee/ de plantes et d'animaux.}vuyde/ et les tenebres estoient sus les 
abysmes/ et \Note[]{*}{Selon les Ebrieux/ ou esperit: car 
{\Hebreu\Dalet\Vav\Het} signifie vent & esperit.}le vent \Note[]{*}{ou/ 
vehement car {\Hebreu\Alef\Lamed\Resh\He\Yod\Memfinal} se prent aucunesfois 
pour hault/ excellent/ & puissant.}de Dieu se demenoit par dessus les eaues.

I’d like to typeset the beginning of that using a different font BigFont (but 
letting lua code to determine the position of closing brace). Ie :

{\BigFont \WORD{i}eu \Note[]{}{Ebrieux \LeftDot 11.a.}crea au commencement le 
ciel et la terre.} Et la terre
estoit \Note[]{*}{{\Hebreu\Tav\He\Vav} c'est a dire/ vaine/ qui ne proffite et 
ne sert a rien.}indisposee et \Note[]{*}{{\Hebreu\Bet\He\Vav} non remplie & 
ornee/ de plantes et d'animaux.}vuyde/ et les tenebres estoient sus les 
abysmes/ et \Note[]{*}{Selon les Ebrieux/ ou esperit: car 
{\Hebreu\Dalet\Vav\Het} signifie vent & esperit.}le vent \Note[]{*}{ou/ 
vehement car {\Hebreu\Alef\Lamed\Resh\He\Yod\Memfinal} se prent aucunesfois 
pour hault/ excellent/ & puissant.}de Dieu se demenoit par dessus les eaues.

To do this I’d need to extract the macros etc… « Worst » case scenario I’ll 
write a simple adhoc lpeg grammar to parse input, but was wondering if such 
grammar existed already in context lua code, or elsewhere.

Thanks

De : Hans Hagen
Envoyé le :mercredi 28 novembre 2018 09:04
À : Joseph Canedo; mailing list for ConTeXt users
Objet :Re: [NTG-context] Grammar to parse TeX input?

On 11/27/2018 11:00 PM, Joseph Canedo wrote:
> I’ve tried context.processbuffer but I am afraid it’s not what I am 
> after, most probably I have not phrased clearly my question.
> 
> What I am looking for is roughly what’s described in Taco’s presentation 
> https://meeting.contextgarden.net/2014/talks/2014-09-12-taco-luatex/luatextalk.pdf
> 
> A way to decompose some input into tokens which represent either normal 
> text, csnames etc…  I had a try to this token library in LuaTeX but I 
> could not find examples of how to use it. I suspect that buffers 
> mechanism use it somehow.
you can pick up stuff from the input so in principle you can start your 
input with a token scanner, but then you not only end up with lots of 
'tokens' but also need to interpret them ... and that is actually what 
tex is quite effecient in and good at, so the question is: what do you 
want to achieve ... there might be better ways

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] Grammar to parse TeX input?

2018-11-28 Thread Hans Hagen

On 11/27/2018 11:00 PM, Joseph Canedo wrote:
I’ve tried context.processbuffer but I am afraid it’s not what I am 
after, most probably I have not phrased clearly my question.


What I am looking for is roughly what’s described in Taco’s presentation 
https://meeting.contextgarden.net/2014/talks/2014-09-12-taco-luatex/luatextalk.pdf


A way to decompose some input into tokens which represent either normal 
text, csnames etc…  I had a try to this token library in LuaTeX but I 
could not find examples of how to use it. I suspect that buffers 
mechanism use it somehow.
you can pick up stuff from the input so in principle you can start your 
input with a token scanner, but then you not only end up with lots of 
'tokens' but also need to interpret them ... and that is actually what 
tex is quite effecient in and good at, so the question is: what do you 
want to achieve ... there might be better ways


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] Grammar to parse TeX input?

2018-11-27 Thread Joseph Canedo
I’ve tried context.processbuffer but I am afraid it’s not what I am after, most 
probably I have not phrased clearly my question.

What I am looking for is roughly what’s described in Taco’s presentation 
https://meeting.contextgarden.net/2014/talks/2014-09-12-taco-luatex/luatextalk.pdf
A way to decompose some input into tokens which represent either normal text, 
csnames etc…  I had a try to this token library in LuaTeX but I could not find 
examples of how to use it. I suspect that buffers mechanism use it somehow.

Thanks

De : Hans Hagen
Envoyé le :lundi 26 novembre 2018 18:55
À : mailing list for ConTeXt users; Joseph Canedo
Objet :Re: [NTG-context] Grammar to parse TeX input?

On 11/26/2018 3:19 PM, Joseph Canedo wrote:
> \startluacode
> 
> function zzz_function(text)
> 
> - How to process ‘text’ to get bits which are macros, groups etc… ? 
> Eventually expanded ?
> 
> end
> 
> \stopluacode
> 
> \definebuffer[ZZZBuffer]
> 
> \def\StartZZZ{\grabbufferdata[ZZZBuffer][StartZZZ][StopZZZ]}
> 
> \def\StopZZZ{\ctxlua{zzz_function(buffers.getcontent('ZZZBuffer'))}}
> 
> \StartZZZ
> 
> \input knuth
> 
> \StopZZZ
context.processbuffer { "ZZZBuffer" }

-
   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] Grammar to parse TeX input?

2018-11-26 Thread Hans Hagen

On 11/26/2018 3:19 PM, Joseph Canedo wrote:

\startluacode

function zzz_function(text)

- How to process ‘text’ to get bits which are macros, groups etc… ? 
Eventually expanded ?


end

\stopluacode

\definebuffer[ZZZBuffer]

\def\StartZZZ{\grabbufferdata[ZZZBuffer][StartZZZ][StopZZZ]}

\def\StopZZZ{\ctxlua{zzz_function(buffers.getcontent('ZZZBuffer'))}}

\StartZZZ

\input knuth

\StopZZZ

context.processbuffer { "ZZZBuffer" }

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

[NTG-context] Grammar to parse TeX input?

2018-11-26 Thread Joseph Canedo
Dear list,

I use a buffer to make some text processing. That text contains TeX macros etc… 
and I’d like to know if there is some feature in lua to parse the text to 
extract bits which macros, normal text etc… ? 
Thanks

Best regards

Joseph

Example of pseudo MWE follows.

\startluacode

function zzz_function(text)
- How to process ‘text’ to get bits which are macros, groups etc… ? Eventually 
expanded ?
end

\stopluacode

\definebuffer[ZZZBuffer]

\def\StartZZZ{\grabbufferdata[ZZZBuffer][StartZZZ][StopZZZ]}
\def\StopZZZ{\ctxlua{zzz_function(buffers.getcontent('ZZZBuffer'))}}

\StartZZZ
\input knuth
\StopZZZ


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