ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] self defined conversion in \date
@ 2024-05-30 11:59 Peter Münster
  2024-05-30 21:01 ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Münster @ 2024-05-30 11:59 UTC (permalink / raw)
  To: ConTeXt users

Hi,

It seems, that you cannot use self defined conversions in \date:

\defineconversion[mytest][X-\romannumerals]
\starttext
Self defined conversion: \convertnumber{mytest}{1} (OK)\\
Predefined conversion in date: \date[d=1][day:a] (OK)\\
Self defined conversion in date: \date[d=1][day:mytest] (not OK)
\stoptext

Is this a bug, or a feature?

How could one use self defined conversions in \date please?

TIA for any help,
-- 
           Peter
___________________________________________________________________________________
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] 4+ messages in thread

* [NTG-context] Re: self defined conversion in \date
  2024-05-30 11:59 [NTG-context] self defined conversion in \date Peter Münster
@ 2024-05-30 21:01 ` Wolfgang Schuster
  2024-05-30 21:22   ` Peter Münster
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Schuster @ 2024-05-30 21:01 UTC (permalink / raw)
  To: ConTeXt users

Peter Münster schrieb am 30.05.2024 um 13:59:
> Hi,
> 
> It seems, that you cannot use self defined conversions in \date:
> 
> \defineconversion[mytest][X-\romannumerals]
> \starttext
> Self defined conversion: \convertnumber{mytest}{1} (OK)\\
> Predefined conversion in date: \date[d=1][day:a] (OK)\\
> Self defined conversion in date: \date[d=1][day:mytest] (not OK)
> \stoptext
> 
> Is this a bug, or a feature?
> 
> How could one use self defined conversions in \date please?

The \date mechanism can only use conversions which are defined on the 
Lua side but your custom conversion is only available on the TeX side.
You can however set the "X-" prefix as normal string in the output of 
\date and use a predefined conversion.

\starttext

\date[d=1][X-,day:r]

\date[d=1][X-,day:romannumerals]

\stoptext

Wolfgang
___________________________________________________________________________________
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] 4+ messages in thread

* [NTG-context] Re: self defined conversion in \date
  2024-05-30 21:01 ` [NTG-context] " Wolfgang Schuster
@ 2024-05-30 21:22   ` Peter Münster
  2024-05-30 21:33     ` Wolfgang Schuster
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Münster @ 2024-05-30 21:22 UTC (permalink / raw)
  To: ConTeXt users

On Thu, May 30 2024, Wolfgang Schuster wrote:

> The \date mechanism can only use conversions which are defined on the Lua side

Ok. How please?

This does not work:

--8<---------------cut here---------------start------------->8---
\startluacode
-- from https://wiki.contextgarden.net/Command/defineconversion:
  interfaces.implement {
    name      = "FRdate",
    public    = true,
    arguments = "string",
    actions   =
        function(s)
            local n = tonumber(s)
            if n == 1 then
                context"1\\ier"
            else
                context(s)
            end
        end
}
\stopluacode
\def\ier{\highordinalstr{er}}
\mainlanguage[fr]
\defineconversion[frd][\FRdate]
\setuplanguage[fr][date={day:frd,\ ,month,\ ,year}]
\starttext
Conversion: \convertnumber{frd}{1}, \convertnumber{frd}{2} (OK)\\
Dates: \date[d=1], \date[d=2] (not OK)
\stoptext
--8<---------------cut here---------------end--------------->8---

-- 
           Peter
___________________________________________________________________________________
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] 4+ messages in thread

* [NTG-context] Re: self defined conversion in \date
  2024-05-30 21:22   ` Peter Münster
@ 2024-05-30 21:33     ` Wolfgang Schuster
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Schuster @ 2024-05-30 21:33 UTC (permalink / raw)
  To: ConTeXt users

Peter Münster schrieb am 30.05.2024 um 23:22:
> On Thu, May 30 2024, Wolfgang Schuster wrote:
> 
>> The \date mechanism can only use conversions which are defined on the Lua side
> 
> Ok. How please?
> 
> This does not work:
> 
> --8<---------------cut here---------------start------------->8---
> \startluacode
> -- from https://wiki.contextgarden.net/Command/defineconversion:
>    interfaces.implement {
>      name      = "FRdate",
>      public    = true,
>      arguments = "string",
>      actions   =
>          function(s)
>              local n = tonumber(s)
>              if n == 1 then
>                  context"1\\ier"
>              else
>                  context(s)
>              end
>          end
> }
> \stopluacode
> \def\ier{\highordinalstr{er}}
> \mainlanguage[fr]
> \defineconversion[frd][\FRdate]
> \setuplanguage[fr][date={day:frd,\ ,month,\ ,year}]
> \starttext
> Conversion: \convertnumber{frd}{1}, \convertnumber{frd}{2} (OK)\\
> Dates: \date[d=1], \date[d=2] (not OK)
> \stoptext
> --8<---------------cut here---------------end--------------->8---


\startluacode
function converters.peter(n)
     return "X-" .. converters.romannumerals(n)
end
\stopluacode

\starttext

\date[d=1][X-,day:romannumerals]

\date[d=1][day:peter]

\stoptext

Wolfgang
___________________________________________________________________________________
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] 4+ messages in thread

end of thread, other threads:[~2024-05-30 21:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-30 11:59 [NTG-context] self defined conversion in \date Peter Münster
2024-05-30 21:01 ` [NTG-context] " Wolfgang Schuster
2024-05-30 21:22   ` Peter Münster
2024-05-30 21:33     ` Wolfgang Schuster

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).