ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Hans Hagen <j.hagen@xs4all.nl>
Subject: Re: [NTG-context] Replacer based on function rathen than tables
Date: Thu, 18 May 2023 16:21:45 +0200	[thread overview]
Message-ID: <b429408f-c4f3-61f7-0003-449e8a279ce3@xs4all.nl> (raw)
In-Reply-To: <CAKyqqaYsK8GLOGPQxBQfVyCN_zk2_4wqM58BStCyHZa-094_gg@mail.gmail.com>

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
___________________________________________________________________________________

      reply	other threads:[~2023-05-18 14:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 12:21 Jairo A. del Rio via ntg-context
2023-05-18 14:21 ` Hans Hagen via ntg-context [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b429408f-c4f3-61f7-0003-449e8a279ce3@xs4all.nl \
    --to=ntg-context@ntg.nl \
    --cc=j.hagen@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).