Re: [NTG-context] Replacer based on function rathen than tables

2023-05-18 Thread Hans Hagen via ntg-context

On 5/18/2023 2:21 PM, Jairo A. del Rio wrote:
Hi, list. There's lang-rep.mkxl and lang-tra.mkxl in the distribution 
which allows replacing a list of words and applying transliteration, 
respectively. Both are based on tables. I want to know if there's a way 
to use a function instead, say


local function nice(str)
    return str .. " is nice"
end

Thanks in advance. Best regards,

I'll add it (one of the more trivial things):

\starttext

\startluacode
languages.replacements.add("basics", {
["one"]   = "cool",
["two"]   = function(s)
return "warm"
end
})
\stopluacode

\start \setreplacements[basics] It's one in here! \stop \par
\start \setreplacements[basics] It's two in here! \stop \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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Replacer based on function rathen than tables

2023-05-18 Thread Jairo A. del Rio via ntg-context
Hi, list. There's lang-rep.mkxl and lang-tra.mkxl in the distribution which
allows replacing a list of words and applying transliteration,
respectively. Both are based on tables. I want to know if there's a way to
use a function instead, say

local function nice(str)
   return str .. " is nice"
end

Thanks in advance. Best regards,

Jairo
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___