From: Taco Hoekwater <taco@elvenkind.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Access current element in xmlsetsetup via xml.expressions
Date: Wed, 2 Oct 2019 10:18:25 +0200 [thread overview]
Message-ID: <2E39AF70-9E74-41DE-B87B-0C3DE20B3585@elvenkind.com> (raw)
In-Reply-To: <014501d5788d$caf67910$60e36b30$@jander.de>
> On 1 Oct 2019, at 21:24, achim@jander.de wrote:
>
> Hello,
> I’m trying to build an xmlsetsetup with an own lua function. XML in MKIV says on pg. 33:
> You can also use normal Lua functions as long as you make sure that you pass the right arguments.
> There are a few predefined variables available inside such functions.
> list table the list of matches
> l number the current index in the list of matches
> ll element the current element that matched
> order number the position of the root of the path
>
> But I can’t figure out how to get access to list, ll etc.
Neither can I :(
Taco
> My MWE (only for testing the access, is always true):
>
> \startbuffer[text]
> <para>Dies ist <inline style="sup">ein</inline> xxx<inline style="sub">zwei</inline> noch ein <inline style="sup">sup</inline> Test<inline style="sub">sub</inline></para>
> \stopbuffer
> %\enabletrackers[xml.parse,xml.path]
>
> \startluacode
> function xml.expressions.nextnodeatt(e)
> inspect(e)
> inspect(ll)
> return('sub')
> end
> \stopluacode
>
> \startxmlsetups xml:textsetups
> \xmlsetsetup{#1}{*}{+}
> \xmlsetsetup{#1}{para}{xml:*}
> \xmlsetsetup{#1}{inline[@style='sup'][xml.expressions.nextnodeatt(ll)=='sub']}{xml:sub}
> \stopxmlsetups
>
> \xmlregistersetup{xml:textsetups}
>
> \startxmlsetups xml:para
> \xmlflush{#1}\par
> \stopxmlsetups
>
> \startxmlsetups xml:sub
> \color[red]{\xmlflush{#1}}
> \stopxmlsetups
>
>
> \starttext
> \xmlprocessbuffer{main}{text}{}
> \stoptext
>
> Thanks in advance,
> Achim
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
Taco Hoekwater
Elvenkind BV
___________________________________________________________________________________
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:[~2019-10-02 8:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 19:24 achim
2019-10-02 8:18 ` Taco Hoekwater [this message]
2019-10-02 10:32 ` mf
2019-10-02 16:52 ` Hans Hagen
2019-10-02 17:48 ` achim
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=2E39AF70-9E74-41DE-B87B-0C3DE20B3585@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).