Hi Hans,

That works for me, I patch the core-con.lua with your implementation, update the local cache by running `mtxrun --script cache --make`, context my document and get the same "as-is" result as before, I think that would be a valuable idea to have an extra as-is function for potential number conversions. 

And I just realize, for Chinese date, only year section follows the as-is pattern, for month or day, December should be represented as 十二月 instead of 一二, twenty-sixth is 二十六日 instead of 二六, we might need to consider to narrow down the name to be year could be more precise and meaningful.

Cheers,
Yihan


On Wed, Nov 29, 2023 at 5:24 PM Hans Hagen <j.hagen@xs4all.nl> wrote:
On 11/29/2023 7:56 AM, Yihan Song wrote:
> Dears,
>
> I am opening a PR <https://github.com/contextgarden/context/pull/1> to
> improve the Chinese date conversion but it seems that repo is just a
> mirror site without development activities, can someone help to review
> this one?

sending patched files is faster (i need to check and diff anyway)

can you test with this:

     if name == "date" then
         -- We could do some number juggling instead but this is fast
enough. There is
         -- no error checking here so we assume a proper year. Maybe a
better name is
         -- asis (so that it can be used for more than dates).
         local vector = vector.normal
         for s in gmatch(tostring(n),".") do
             r = r + 1 ; result[r] = vector[tonumber(s)]
         end
         return concat(result)
     end

(btw, we also need to adapt the lmt file ... once mkiv is frozen we only
add to lmtx)

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