* [NTG-context] Fwd: Re: Replacing %20 with spaces in xml attributes
[not found] <b4ca1196-260d-0c15-8f93-dd1840fd3bfd@freedom.nl>
@ 2023-07-21 15:50 ` Hans Hagen via ntg-context
0 siblings, 0 replies; only message in thread
From: Hans Hagen via ntg-context @ 2023-07-21 15:50 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Hans Hagen
-------- Forwarded Message --------
Subject: Re: [NTG-context] Re: Replacing %20 with spaces in xml attributes
Date: Fri, 21 Jul 2023 17:50:04 +0200
From: Hans Hagen <j.hagen@freedom.nl>
To: denis.maier@unibe.ch
On 7/21/2023 5:27 PM, denis.maier@unibe.ch wrote:
> Thanks, but I'm still getting the same error. I'm thinking that it has something to do with the percent characters...
>
> This here works just fine:
>
> \startluacode
> function test(s)
> result = string.gsub(s, 'x20', 'MATCH')
> context(result)
> end
> \stopluacode
>
> \define[1]\test{\ctxlua{test("#1")}}
>
> \starttext
> \test{asdfx20} % -> asdfMATCH
> \stoptext
>
> But this here won't:
>
> \startluacode
> function test(s)
> result = string.gsub(s, '%%20', 'MATCH')
> context(result)
> end
> \stopluacode
>
> \define[1]\test{\ctxlua{test("#1")}}
>
> \starttext
> \test{asdf%20} % -> does not work
> \stoptext
>
> Any ideas?
\startluacode
function xml.finalizers.tex.url(e,a)
local u = #e > 0 and e[1].at[a]
local s = u and lpeg.match(lpeg.patterns.urlunescaper,u)
context(s)
end
\stopluacode
\startxmlsetups xml:something
\xmlatt{#1}{xlink:href}\par
\xmlfilter{#1}{./url('xlink:href')}
\stopxmlsetups
i'll add this
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-07-21 15:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <b4ca1196-260d-0c15-8f93-dd1840fd3bfd@freedom.nl>
2023-07-21 15:50 ` [NTG-context] Fwd: Re: Replacing %20 with spaces in xml attributes Hans Hagen via ntg-context
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).