From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HTML_MESSAGE,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31568 invoked from network); 21 Jul 2023 14:32:33 -0000 Received: from cgl.ntg.nl (5.39.185.202) by inbox.vuxu.org with ESMTPUTF8; 21 Jul 2023 14:32:33 -0000 Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 371C3482B24 for ; Fri, 21 Jul 2023 16:29:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aQYlux7OQr31 for ; Fri, 21 Jul 2023 16:29:47 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 132DE482B74 for ; Fri, 21 Jul 2023 16:27:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id CD20D482A13 for ; Fri, 21 Jul 2023 16:27:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q0eZoJOe2jgR for ; Fri, 21 Jul 2023 16:27:31 +0200 (CEST) Received: from smtpq1.tb.mail.iss.as9143.net (smtpq1.tb.mail.iss.as9143.net [212.54.42.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cgl.ntg.nl (Postfix) with ESMTPS id 95F2A482A07 for ; Fri, 21 Jul 2023 16:27:31 +0200 (CEST) Received: from [212.54.42.190] (helo=csmtpq3-prd-nl1-vfz.edge.unified.services) by smtpq1.tb.mail.iss.as9143.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMr6Q-0001Ot-E1 for ntg-context@ntg.nl; Fri, 21 Jul 2023 16:27:30 +0200 Received: from csmtp4-prd-nl1-vfz.nl1.unified.services ([100.107.80.18]) by csmtpq3-prd-nl1-vfz.edge.unified.services with esmtp (Exim 4.93) (envelope-from ) id 1qMr4g-001rJO-VY for ntg-context@ntg.nl; Fri, 21 Jul 2023 16:25:42 +0200 Received: from smtpclient.apple ([84.104.102.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 128/128 bits) (Client did not present a certificate) by VodafoneZiggo with ESMTPSA id Mr4gqQP5nDN23Mr4gqYiuA; Fri, 21 Jul 2023 16:25:42 +0200 X-Env-Mailfrom: havdmeer@ziggo.nl X-Env-Rcptto: ntg-context@ntg.nl X-SourceIP: 84.104.102.59 X-CNFS-Analysis: v=2.4 cv=Au8onsxP c=1 sm=1 tr=0 ts=64ba9566 cx=a_exe a=r8aFSP8g8qyxuwAfcqn69g==:117 a=r8aFSP8g8qyxuwAfcqn69g==:17 a=z_5uEx5cAAAA:8 a=MiNTnEJAAAAA:8 a=YEMqx4UAAAAA:8 a=ACQCx6kCAAAA:8 a=xtERp6CFAAAA:8 a=a3nu-2BBAAAA:8 a=ZxLxpqDEGsRyLbTCD8YA:9 a=QEXdDO2ut3YA:10 a=9Ggj1JQVzDA_vl8YpPUA:9 a=Gb1jXfIyBb5Sprdb:21 a=_W_S_7VecoQA:10 a=lqcHg5cX4UMA:10 a=JtrFjcrP6MhGCbC1Nd-z:22 a=LmrbSfiT3hecnSZifb5M:22 a=V0662LiR8DSfwiDagK97:22 a=Sab0UneHBzlWrQDlOuxD:22 a=ekCXXmE-vB8RPiJ3MEZb:22 X-Authenticated-Sender: havdmeer@ziggo.nl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ziggo.nl; s=202002corplgsmtpnl; t=1689949542; bh=Uxt1O24Y9bTWd8iVMKzJEC9SGr9ls9qKtqwUWM5UaRI=; h=From:Subject:Date:References:To:In-Reply-To; b=Zeu/OlgV16FgrFntvm+o4aRmuKbBnislSEk3DSS2Ziel1Jns7h8K0CtWE6WQr2OJp dJDSJRiau0YuALay1C8WF5G6qwAtIzb/98w8sLPZhY6MBiofoxGygaJe3tUG5ld9os KoIYwWCHXbWs+f76smRtQxYRJtV5OaMshJ4botZl51o5kbdC4GKf1YWqS70AWiBP5d MX+APpJ62fiJUllxsrJ0rhnjr/iwEGv8yGCoPX0Dgo3XBoyxdNKunXp2mCe9CWT7Dm 4MzG6g04NrWXk0qJ/LG1tm5usm0V9zFAgdpPpPRzL1L6DfrPFN2zmOjHLADyexpe21 lCiIS54IctVSw== Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Date: Fri, 21 Jul 2023 16:25:30 +0200 References: To: NTG ConTeXt In-Reply-To: Message-Id: <04222291-1CA6-46C8-A9BA-4DE75C76F5C0@ziggo.nl> X-Mailer: Apple Mail (2.3731.600.7) X-CMAE-Envelope: MS4xfAkLwoTtLlDdcUL6AXfkc8bIsFDBgCERaTJTlhcCch6VP04zcR9TAPBdEsC4NzkqK0rd8m/8zRgDlaPb0ZoZ2xoB9B5Eu51a6HOcHOqV1C+K19osVaZV fum0zEi1Ykdf1Tf1GiUHU075817iDTJxhFQiVvxFHwdrYSB4mJq3kFboT9tAELMJlQuSvRoKSSAMhw== Message-ID-Hash: MXWRSCRJY5OCYMIMDNJKNT3ALIBK6E5G X-Message-ID-Hash: MXWRSCRJY5OCYMIMDNJKNT3ALIBK6E5G X-MailFrom: havdmeer@ziggo.nl X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Re: Replacing %20 with spaces in xml attributes List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Hans van der Meer via ntg-context Cc: Hans van der Meer Content-Type: multipart/mixed; boundary="===============0092779787651343864==" --===============0092779787651343864== Content-Type: multipart/alternative; boundary="Apple-Mail=_7F5513AC-08A1-4159-8535-14873721528A" --Apple-Mail=_7F5513AC-08A1-4159-8535-14873721528A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Here in Terminal on my Mac: 21 ~: lua Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio > string.gsub('a%20b', '%%20', ' ') a b 1 > (string.gsub('a%20b', '%%20', ' ')) a b > ^D 21 ~:=20 The first call returns the 1 giving the match, the extra ()'s get rid of = that second return value. yours sincerely dr. Hans van der Meer > On 21 Jul 2023, at 12:37, denis.maier@unibe.ch wrote: >=20 > Hi, > =20 > I=E2=80=99m typesetting an XML document where the links to the images = contain spaces which are encoded as %20 > > =20 > Using this works in cases without spaces: > =20 > \startxmlsetups xml:fig:graphic > \externalfigure[\xmlatt{#1}{xlink:href}] > \stopxmlsetups > =20 > This also works for normal spaces, but is there a way to decode/expand = the %20s to regular spaces? > =20 > I=E2=80=99ve tried with some Lua, but I don=E2=80=99t really know how = to pass data around. > =20 > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > \startluacode > function replaceSpaces(s) > result =3D string.gsub(s, "%%20", " ") > context(result) > end > \stopluacode > =20 > \define[1]\replaceSpaces{\ctxlua{replaceSpaces("#1")}} > =20 > \startxmlsetups xml:fig:graphic > \externalfigure[\replaceSpaces{\xmlatt{#1}{xlink:href}}] > \stopxmlsetups > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > =20 > Any hints, why this does not work?` > =20 > Also, maybe there=E2=80=99s a simpler way for this kind of scenario? >=20 > Best, > Denis > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_7F5513AC-08A1-4159-8535-14873721528A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Here in = Terminal on my Mac:

21 ~: = lua

Lua 5.4.6  = Copyright (C) 1994-2023 Lua.org, PUC-Rio

> = string.gsub('a%20b', '%%20', ' ')

a b = 1

> = (string.gsub('a%20b', '%%20', ' '))

a b

> ^D

21 = ~: 


The first call = returns the 1 giving the match, the extra ()'s get rid of that second = return value.

yours sincerely
dr. Hans van der = Meer



On 21 Jul 2023, at 12:37, = denis.maier@unibe.ch wrote:

Hi,
 
I=E2=80=99m typesetting an XML document where the links = to the images contain spaces which are encoded as = %20
<graphic = xlink:href=3D"a%20filename%20with%20spaces.jpg"/>
 
Using this works in cases without = spaces:
 
\startxmlsetups xml:fig:graphic
  = \externalfigure[\xmlatt{#1}{xlink:href}]
\stopxmlsetups
 
This also works for = normal spaces, but is there a way to decode/expand the %20s to regular = spaces?
 
I=E2=80=99ve tried with some Lua, but I don=E2=80=99t = really know how to pass data around.
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\startluacode
function = replaceSpaces(s)
  result =3D = string.gsub(s, "%%20", " ")
  = context(result)
end
\stopluacode
 
\define[1]\replaceSpaces{\ctxlua{replaceSpaces("#1")}}
 
\startxmlsetups = xml:fig:graphic
  = \externalfigure[\replaceSpaces{\xmlatt{#1}{xlink:href}}]
<= div style=3D"margin: 0cm; font-size: 11pt; font-family: Calibri, = sans-serif;">\stopxmlsetups
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
Any hints, why this = does not work?`
 
Also, maybe there=E2=80=99s a simpler way for this kind of = scenario?

Best,
Denis
_____________________________________________________________= ______________________
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
_____________________________________________________________= ______________________

= --Apple-Mail=_7F5513AC-08A1-4159-8535-14873721528A-- --===============0092779787651343864== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============0092779787651343864==--