* [NTG-context] Using \commalistsentence in combination with \processcommacommand... I'm going mad?
@ 2025-09-17 4:18 Andres Conrado Montoya
2025-09-17 7:28 ` [NTG-context] " Hans Hagen via ntg-context
0 siblings, 1 reply; 2+ messages in thread
From: Andres Conrado Montoya @ 2025-09-17 4:18 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 2662 bytes --]
Hi list. This is probably the wrong thing to do. However, it's what I have
been trying:
% MWE %%%%%%%%%%%%%%%%%%%%%%
% Registro de autores
\definenamespace[autores][
type=module,
name=autor,
command=yes,
parent=autores,
]
\define[1]\AutorNombreApellido{\edef\currentautor{#1}{%
\doifsomething{\autorparameter{nombres}}{\autorparameter{nombres}\space}%
\doifsomething{\autorparameter{apellidos}}{\autorparameter{apellidos},}%
}}
\define[1]\ListaAutores{{\AutorNombreApellido{#1}}\space}
\define\autoresListaH{\processcommacommand[\documentvariable{autores}]\ListaAutores}
\defineautor[autores][rol={autor}]
\defineautor[andi][autores][nombres={Andrés Conrado}, apellidos={Montoya
Acosta}]
\defineautor[soni][autores][nombres={Sonia Amparo}, apellidos={Rodríguez
Rodríguez}]
\defineautor[sofi][autores][nombres={Sofía}, apellidos={Parra Albarracín}]
\startdocument[autores={andi,soni,sofi}]
\commalistsentence[\documentvariable{autores}][{;\space},{\space\letterampersand\space}]
\blank[big]
\commalistsentence[\autoresListaH][{;\space},{\space\letterampersand\space}]
\stopdocument
%%%%%%%%%%%%%%%%%%%%%%%%%
As you may see, I'm trying to process a list of authors, based on the
examples in https://wiki.contextgarden.net/Command/startdocument and
https://wiki.contextgarden.net/Command/commalistsentence. But this is
getting convoluted and I'm convinced there must be an obvious simpler
solution I can't seem to find.
- The output comes out `Andrés Conrado Montoya Acosta, Sonia Amparo
Rodríguez Rodríguez, Sofía Parra Albarracín,`
- I want `Andrés Conrado Montoya Acosta; Sonia Amparo Rodríguez Rodríguez &
Sofía Parra Albarracín` as the first line in the output: `andi; soni & sofi`
I think I am doing something wrong, because probably it's possible to set
up the \processcommacommand to act in the same way as the
\commandlistsentence? (I'm guessing this is what I want) But I can't seem
to find how.
Also consulted:
-
https://wiki.contextgarden.net/ConTeXt_and_Lua_programming/Tutorials/System_Macros/Action_Processing
-
https://wiki.contextgarden.net/ConTeXt_and_Lua_programming/Tutorials/System_Macros/Comma_Separated_Lists
Something there should help but I'm not really sure what. Any clue would be
greatly appreciated. Thank you very much.
--
Andrés Conrado Montoya
andresconrado@gmail.com
http://sesentaycuatro.com
----------------------------------------
Los fines no justifican los medios, porque la medida verdadera de nuestro
carácter está dada por los medios que estamos dispuestos a utilizar, no por
los fines que proclamamos.
[-- Attachment #1.2: Type: text/html, Size: 3654 bytes --]
[-- Attachment #2: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread* [NTG-context] Re: Using \commalistsentence in combination with \processcommacommand... I'm going mad?
2025-09-17 4:18 [NTG-context] Using \commalistsentence in combination with \processcommacommand... I'm going mad? Andres Conrado Montoya
@ 2025-09-17 7:28 ` Hans Hagen via ntg-context
0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen via ntg-context @ 2025-09-17 7:28 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
On 9/17/2025 6:18 AM, Andres Conrado Montoya wrote:
> \definenamespace[autores][
> type=module,
> name=autor,
> command=yes,
> parent=autores,
> ]
>
> \define[1]\AutorNombreApellido{\edef\currentautor{#1}{%
> \doifsomething{\autorparameter{nombres}}{\autorparameter{nombres}\space}%
> \doifsomething{\autorparameter{apellidos}}{\autorparameter{apellidos},}%
> }}
>
> \define[1]\ListaAutores{{\AutorNombreApellido{#1}}\space}
> \define\autoresListaH{\processcommacommand[\documentvariable{autores}]\ListaAutores}
>
> \defineautor[autores][rol={autor}]
> \defineautor[andi][autores][nombres={Andrés Conrado}, apellidos={Montoya
> Acosta}]
> \defineautor[soni][autores][nombres={Sonia Amparo}, apellidos={Rodríguez
> Rodríguez}]
> \defineautor[sofi][autores][nombres={Sofía}, apellidos={Parra Albarracín}]
>
> \startdocument[autores={andi,soni,sofi}]
>
> \commalistsentence[\documentvariable{autores}][{;\space},
> {\space\letterampersand\space}]
>
> \blank[big]
>
> \commalistsentence[\autoresListaH][{;\space},{\space\letterampersand\space}]
>
> \stopdocument
Take your choice ... two approached, one a bit mkii-ish, the other more
lmtx-ish (both ok, all depends on specific needs)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\starttexdefinition AutorNombreApellido #1
\edef\currentautor{#1}%
\doifsomething {\autorparameter{nombres}} {
\autorparameter{nombres}
\space
}
\doifsomething {\autorparameter{apellidos}} {
\autorparameter{apellidos}
}
\stoptexdefinition
% \starttexdefinition AutorNombreApellido #1
% \edef\currentautor{#1}%
% \unless \ifempty {\autorparameter{nombres}}
% \autorparameter{nombres}
% \space
% \fi
% \unless \ifempty {\autorparameter{apellidos}}
% \autorparameter{apellidos}
% \fi
% \stoptexdefinition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\starttexdefinition AutorWhatever #1
\scratchcounterone\zerocount
\scratchcountertwo\zerocount
\doloopovermatch {(\letterpercent w+)} {#1} {
\advance\scratchcounterone\plusone
}
\doloopovermatch {(\letterpercent w+)} {#1} {%
\advance\scratchcountertwo\plusone
\ifnum\scratchcountertwo=\plusone
% nothing
\orelse\ifnum\scratchcountertwo=\scratchcounterone
\space\letterampersand\space
\else
;\space
\fi
\AutorNombreApellido{##1}%
}
\stoptexdefinition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\starttexdefinition AutorWhateverIndeed #1
\advance\scratchcountertwo\plusone
\ifnum\scratchcountertwo=\plusone
% nothing
\orelse\ifnum\scratchcountertwo=\scratchcounterone
\space\letterampersand\space
\else
;\space
\fi
\AutorNombreApellido{#1}%
\stoptexdefinition
\starttexdefinition AutorWhateverX #1
\getcommacommandsize[#1]%
\scratchcounterone\commalistsize
\scratchcountertwo\zerocount
\processcommacommand[#1]\AutorWhateverIndeed
\stoptexdefinition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\defineautor[autores][rol={autor}]
\defineautor[andi][autores][nombres={Andrés Conrado}, apellidos={Montoya
Acosta}]
\defineautor[soni][autores][nombres={Sonia Amparo}, apellidos={Rodríguez
Rodríguez}]
\defineautor[sofi][autores][nombres={Sofía}, apellidos={Parra Albarracín}]
\definenamespace[autores][
type=module,
name=autor,
command=yes,
parent=autores,
]
\startdocument[autores={andi,soni,sofi}]
1: \AutorWhatever{\documentvariable{autores}} \blank
2: \AutorWhatever{andi,soni,sofi} \blank
3: \AutorWhatever{andi,soni} \blank
4: \AutorWhatever{soni} \blank
1: \AutorWhateverX{\documentvariable{autores}} \blank
2: \AutorWhateverX{andi,soni,sofi} \blank
3: \AutorWhateverX{andi,soni} \blank
4: \AutorWhateverX{soni} \blank
\stopdocument
-----------------------------------------------------------------
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 / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-17 7:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-17 4:18 [NTG-context] Using \commalistsentence in combination with \processcommacommand... I'm going mad? Andres Conrado Montoya
2025-09-17 7:28 ` [NTG-context] " Hans Hagen via ntg-context
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).