From: Taco Hoekwater <taco@elvenkind.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Greek in luatex
Date: Thu, 13 Sep 2007 13:38:03 +0200 [thread overview]
Message-ID: <46E9211B.5020206@elvenkind.com> (raw)
In-Reply-To: <20070913102426.GA10571@phare.normalesup.org>
[-- Attachment #1: Type: text/plain, Size: 464 bytes --]
Arthur Reutenauer wrote:
>> Yes, except that we need a more powerful version (almost like OTPs) if
>> we want to handle transcriptions properly. The vital point is that it
>> should operate on tokens, not on nodes.
>
> Yes, sure. OTP would work fine here, but I thought Mark IV had already
> something handy.
I played a bit, see attachment. Surely Hans will want to improve on this
interface, so don't patch any of the core files just now.
Best wishes,
Taco
[-- Attachment #2: tokfilter.tex --]
[-- Type: text/x-tex, Size: 1751 bytes --]
% engine=luatex
%D First a hack to the core. two changes:
%D * don't force end_cs to be \relax
%D * don't remove end_cs from the input stream
\ctxlua{
function collectors.install(tag,end_cs)
collectors.data[tag] = { }
local data = collectors.data[tag]
local call = token.command_id("call")
local endcs = token.csname_id(end_cs)
local expand = collectors.registered
local get = token.get_next
while true do
local t = get()
local a, b = t[1], t[3]
if b == endcs then
tex.print('\\' ..end_cs)
return
elseif a == call and expand[b] then
token.expand()
else
data[\string#data+1] = t
end
end
end
}
%D a small extension to the core interface, to have a
%D nice wrapper around the lua code
\ctxlua {
function collectors.handle(tag,handle)
collectors.data[tag] = handle(collectors.data[tag])
end
}
\def\handletokens[#1][#2]{\ctxlua{collectors.handle("#1",#2)}}
%D Here starts the document-specific code
%D Start capturing tokens in the buffer named 'babel', stop
%D at \stopbabel
\def\startbabel
{\ctxlua{collectors.install("babel", "stopbabel")}}
%D The lua mutation function. str is a table containing the captured
%D tokens, each itself a three-item table (this is explained in the
%D luatex manual)
\ctxlua {
function convert_babel(str)
local t = { }
for k,v in ipairs(str) do
t[\string#t+1] = tokens.other('*')
t[\string#t+1] = v
end
return t
end
}
%D convert the tokens using that lua function, then
%D flush the result
\def\stopbabel
{\handletokens[babel][convert_babel]
\flushtokens[babel]}
\starttext
\startbabel%
some stuff here
\stopbabel
\stoptext
[-- Attachment #3: Type: text/plain, Size: 487 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2007-09-13 11:38 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-01 10:56 Thomas A. Schmitz
2007-09-11 6:47 ` Thomas A. Schmitz
2007-09-11 10:12 ` Hans Hagen
2007-09-13 1:15 ` Arthur Reutenauer
2007-09-13 7:03 ` Taco Hoekwater
2007-09-13 10:24 ` Arthur Reutenauer
2007-09-13 11:38 ` Taco Hoekwater [this message]
2007-09-13 12:54 ` Thomas A. Schmitz
2007-09-13 18:36 ` Arthur Reutenauer
2007-09-13 18:49 ` Hans Hagen
2007-09-13 19:24 ` Hans Hagen
2007-09-13 19:45 ` Arthur Reutenauer
2007-09-13 20:20 ` Hans Hagen
2007-09-14 0:24 ` Arthur Reutenauer
2007-09-13 20:38 ` Thomas A. Schmitz
2007-09-13 21:05 ` Hans Hagen
2007-09-13 21:52 ` Taco Hoekwater
2007-09-15 23:22 ` Arthur Reutenauer
2007-09-16 6:56 ` Taco Hoekwater
2007-09-16 8:22 ` Taco Hoekwater
2007-09-16 13:01 ` Thomas A. Schmitz
2007-09-16 23:12 ` Hans Hagen
2007-09-16 13:08 ` Arthur Reutenauer
2007-09-16 13:44 ` Thomas A. Schmitz
2007-09-17 8:48 ` Hans Hagen
2007-09-13 17:42 ` Hans Hagen
2007-09-13 9:45 ` Thomas A. Schmitz
2007-09-13 10:49 ` Arthur Reutenauer
2007-09-13 12:51 ` Thomas A. Schmitz
2007-09-13 14:25 ` Taco Hoekwater
2007-09-13 17:51 ` Hans Hagen
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=46E9211B.5020206@elvenkind.com \
--to=taco@elvenkind.com \
--cc=ntg-context@ntg.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).