From: "Meer, Hans van der" <H.vanderMeer@uva.nl>
To: NTG ConTeXt <ntg-context@ntg.nl>
Subject: Re: directlua in xml-environment
Date: Mon, 14 Nov 2016 08:50:52 +0000 [thread overview]
Message-ID: <7FCEAD20-AF9C-44FF-A7C1-6265A3A7E674@uva.nl> (raw)
In-Reply-To: <b761c0c0-5ba6-5646-1926-5407e2650f13@wxs.nl>
Beste Hans,
Je bent weer terug, alles goed met je, hoop ik.
Twee opmerkingen hier.
(1) Inmiddels na veel pogingen ook een andere oplossing gevonden: tex.print(0,string) i.p.v. tex.print(string). Het duurde nogal lang voordat ik doorhad wat het LuaTeX-manual bedoelde. De truc met tex.print(0,string) bleek nodig om een comma-list komend uit een \xmlatt te kunnen verwerken. Ik heb het zo opgelost, misschien iet de beste manier maar het werkt wel:
-- Return comma separated list called with macro name:
hvdm.commalist = function (name, argument)
local s
for s in string.gmatch(argument,"%a+") do
tex.print(0,"\\"..name.."{"..s.."}")
end
end
in een macro aangeroepen met: \directlua{hvdm.commalist("name","#1")}
(2) Ik heb de door mij aangevulde \xmlchainatt en \xmlchainattdef in een aantal situaties gebruikt en zo te zien werkt het nu zoals ik uit de xml-mkiv manual begrijp: afbreken zodra er een match is en in geval van ..def de default teruggeven. Ik recapituleer voor het gemak nog even de veranderingen in lxml-tex.lua, in mijn versie vanaf regel 1407:
local function chainattribute(collected,arguments,default) -- AANGEVULD MET ,default
if collected and #collected > 0 then
local e = collected[1]
while e do
local at = e.at
if at then
local a = at[arguments]
if a then
contextsprint(notcatcodes,a)
return -- RETURN TOEGEVOEGD
end
else
break -- error
end
e = e.__p__
end
end
if default then -- DEZE IF TOEGEVOEGD
contextsprint(notcatcodes,default)
end
end
Ik hoop dat het de weg naar de volgende beta vindt en dat ik hiermee weer een bescheiden bijdrage heb kunnen leveren aan het ConTeXt-'kunstwerk'.
met vriendelijke groet
Hans van der Meer
> On 13 Nov 2016, at 18:23, Hans Hagen <pragma@wxs.nl> wrote:
>
> On 11/13/2016 2:56 PM, Meer, Hans van der wrote:
>> Here is something I do not understand. Possibly I am doing something wrong.
>>
>> The following code is fine, within <<>> the current contextversion is printed.
>> \def\mymacro{\directlua{tex.print("\\contextversion")}}
>> \starttext
>> calling mymacro <<\mymacro>>\par
>> \stoptext
>>
>> However calling \mymacro from inside \startxmlsetup .. \stopxmlsetup does not work and results in <<\contextversion>>. I guess that the catcode regime in that environment is to blame.
>> But how do I change that in order to get things working? I looked into the LuaTeX-manual where catcodes in relation to tex.print are treated, but in vain and could not find how to.
>>
>> What do I have to change?
> \starttexcode
> ...
> \stoptexcode
>
>> Hans van der Meer
>>
>>
>>
>>
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2016-11-14 8:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-13 13:56 Meer, Hans van der
2016-11-13 17:23 ` Hans Hagen
2016-11-14 8:50 ` Meer, Hans van der [this message]
2016-11-17 8:57 ` 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=7FCEAD20-AF9C-44FF-A7C1-6265A3A7E674@uva.nl \
--to=h.vandermeer@uva.nl \
--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).