From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32503 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: Lua Filter: Change image alt= attribute Date: Fri, 28 Apr 2023 22:58:07 +0200 Message-ID: References: <0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000008a92f105fa6bbb75" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8373"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCWMVYEK54FRB3HGWCRAMGQED2LKNLY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Apr 28 22:58:25 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qt1-f191.google.com ([209.85.160.191]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1psVAe-0001wb-Ta for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 28 Apr 2023 22:58:24 +0200 Original-Received: by mail-qt1-f191.google.com with SMTP id d75a77b69052e-3f0aa5fef57sf2155831cf.3 for ; Fri, 28 Apr 2023 13:58:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1682715503; cv=pass; d=google.com; s=arc-20160816; b=MK/tsPv++WSwOBU0MCVSwu0//A3TSs+MVWA0fZ53N75wwSPqG0ze9+YkG73TJ5jXgX w5zq9PZVZDgMDTMhwJUNBIBFsIMuLZ7Nfvm/8TFsdlZJSh25StICjUVIG0T11PotzAz7 o8nNI6IWfaJusYL3Y+H+kkMOvf2oAbGGYeImz/gPIoZQ3TLG72ZoWXVFYunS1uxgzWmc CgYJ3njh8wyLcPrq7JBXq9/zVnuetfmODlEiN7Ik4cfcfo9Du9aU3lqaI1gZ0i76VGi4 xNHtt2n8Qd8L/X1aRggFJk/KIUW3UkJKRRBh/t9vc4HpD+YbKEoFEZvdJAo7g/xuibOo U39Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:sender:dkim-signature; bh=V1oqADebwRaJIBw0y0dWPKduVvSRGDSHWUV27uVWWW0=; b=qyoiPkx2Af0M0KifK1ynm4qlAhREkflSO7ZwwqRklZm9arnaoIzoilHPC19RCScfGG ruMiJEFzhfU5V97AGEpQsI4LcLwhnPX2SpQ+OrGqJzOyZspLfthje5whNf09/4RhY1wv asROY8mtGku9T2hWQYBVS9wSSk7ej9svQSP9jMe5eLANQ+xK4idzloFeINOC0VMfcUrS CiyizGZUSO9ytltAOGYbhm1MqpKJc0bO931dVNW9cCQGdkjAchiKJf6ttGCqezMSqEG4 OyQ73aaeAQFi5b/I5glgM1cTVR8B3E3Tm4lQz5g2nHcqBUDVfayMVU3xp1X534RJUJP/ JKGA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.128.172 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1682715503; x=1685307503; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:to:subject:message-id:date:from:reply-to :in-reply-to:references:mime-version:sender:from:to:cc:subject:date :message-id:reply-to; bh=V1oqADebwRaJIBw0y0dWPKduVvSRGDSHWUV27uVWWW0=; b=R8rEekF67tlOnL9hfV5NQVvrD/FbBupPtks0Mgbh2LAs21lDDdHLiboU0gme7VJ8Lj ziTUEWeR63k5dyB+fXfqC2pSpqbPPipODNYP8o9Nf7CTuFPLQleVszCoGkzu2cRx7llM qnkDRheVDn05I2o1UVfK5UqQWk13+XA9h5GK5H15lpEuKEXby+dQo8dTfKQ8nkEyFY4k cZC2HE7oZ7/h1tpaxVZyF7MhWAJhBze/cmM8uWr008LY355AX9PPlqxAK+w69CNezB75 l1AWhfAZ7M7Ttfah16Ie0ExEzilyrACXJ5Cw2C6fAui7R0S4oiynJ3UB2XPkpvAilU83 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682715503; x=1685307503; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:reply-to:in-reply-to:references:mime-version :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=V1oqADebwRaJIBw0y0dWPKduVvSRGDSHWUV27uVWWW0=; b=bzznQhN3GJoySoiJpnsZo2XHK4M6FvhYxm1GNukUvauDW+EvsPuI9EUJZ/LuchBKig 3rD+xkJvrgRZvhfn4rVcAFMbuxpc2KxT/Mcu8Byk41+HK41CS2WJi1F1Dbz3nk9qG7Dx WnUmjWtMLunOGIeCv8PtbNgzDbAfIEsAaB6d7eo6S864krJZj7fYh9l51ps8jB4Ws0zu WTog+ZQmVlElnEx4g0N/WlFKTiM0qese4lgn0vsDLSikzZFfZPxPHbkh7InMFTMjfISt wontM5 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDxG8C/wDX7g6GwtJ/svNVYVUuB5/N8P6j3Zv/ghYGSgm+TlV0AA giQKfiz30S+iok3F2wrsLXLXQA== X-Google-Smtp-Source: ACHHUZ7EUjxFKbXYIVMmBWZ1U3g6Y+5J1eXlII4Vn7GcunOQhvVe/PsLxGi0CQFoiqtPBQidtWuV0g== X-Received: by 2002:a05:622a:181c:b0:3f1:fc85:9d74 with SMTP id t28-20020a05622a181c00b003f1fc859d74mr1867220qtc.6.1682715503744; Fri, 28 Apr 2023 13:58:23 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6214:bce:b0:5e8:5d19:1c9d with SMTP id ff14-20020a0562140bce00b005e85d191c9dls3857984qvb.6.-pod-prod-gmail; Fri, 28 Apr 2023 13:58:20 -0700 (PDT) X-Received: by 2002:ad4:5c84:0:b0:5ef:4bc2:c03d with SMTP id o4-20020ad45c84000000b005ef4bc2c03dmr13011464qvh.1.1682715500394; Fri, 28 Apr 2023 13:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682715500; cv=none; d=google.com; s=arc-20160816; b=Qus1LsxKhZuxD0zhUwAvi8eJpeOtIvA6sa9kEyfZRp3r32MhBn5fA8f9cnBVt+2Hjs eMlXPB8GbX8rNZboI0ZrhMn1+aQU9Oe82HAY4jBJwKcKWIX93bGpHu7CpCegCKIDvKqs bFzvFXJBW5ycXuPut64lPip3yW+myB1813Zxfg0liB9LBLtX8gDkPOuOvk9lBM6jzNx6 kQ72aFnPf9nehLlLHZYmEKu/JyYC1LaXUfRGBXMnbqga4rci+3vlZVUqaOCivU3USflq zV9Q04Ge8reF7/zWXGFiPuVwtK/liR4T7QCBiDdc6Lde+TO2XEkDUXT7XxPvNrbcaP4+ 0gaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version; bh=hSEvFfTMZtTJxW/Rly2/CopCOBCehSbdfKwo97dHDok=; b=BCpo7QHkM8CEgOV85UgAexvGBUc424RBVo49OA5TLJPhaASpRyZBWBT1UBzebpwy3B VrSidTe6RZ9+cZOLzk9XF696rD3NDutAefcEkPclq2kmm4B25OAxSSx9dI3zNl0Oryg4 7mh7zLhO05KGBTyEN+Qppgz8y9/or0wznEwAyEF3AWPqijvqjE7Cti1Ayb5G0qnRl1z4 eZDKVg5Jv65iybd1je3ltLovrl+EnrlE6g/aF1JvjC65GZ8We39O+xEgVwVCF5l43jlX apF2JyS1YY4DFr2UmCdpz4lryFrhUZX7katiaIm2M6ENDCbyAj05UBNOzyOOClSOCgzU c7Rw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.128.172 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Original-Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com. [209.85.128.172]) by gmr-mx.google.com with ESMTPS id on9-20020a056214448900b005fc5135c65csi1181759qvb.4.2023.04.28.13.58.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Apr 2023 13:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.128.172 as permitted sender) client-ip=209.85.128.172; Original-Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-54f99770f86so4756607b3.1 for ; Fri, 28 Apr 2023 13:58:20 -0700 (PDT) X-Received: by 2002:a81:6a41:0:b0:54f:9de8:fd61 with SMTP id f62-20020a816a41000000b0054f9de8fd61mr4727652ywc.12.1682715498417; Fri, 28 Apr 2023 13:58:18 -0700 (PDT) In-Reply-To: <0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.128.172 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:32503 Archived-At: --0000000000008a92f105fa6bbb75 Content-Type: text/plain; charset="UTF-8" You want `image.caption = 'image'` Den fre 28 apr. 2023 17:25ThomasH skrev: > I want to change the alt= attribute of an image during translation. This > is my Lua filter: > > > > > > *function Image(elem) nelem = elem:clone() nelem.attributes.alt = > 'image' return nelemend* > > It doesn't work, though. With HTML like > > > http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > > > > See image: foobar > > > > I get an AST like this > > [ Plain > [ Str "See" > , Space > , Str "image:" > , Space > , Image > ( "" , [] , [ ( "alt" , "image" ) ] ) > [ Str "foobar" ] > ( "foo.jpg" , "" ) > ] > ] > > I'm not sure how to interprete the Image part, though. The Markdown output > is: > > See image: ![foobar](foo.jpg){alt="image"} > > which shows that the original alt text is retained, and the intended > replacement text is just added as if an arbitrary attribute. > > What is wrong with my filter? > > Thanks, T. > > -- > You received this message because you are subscribed to the Google Groups > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n%40googlegroups.com > > . > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhD1xpL-Re2M8tUQq8DiZNM%3DdXNw8tQ%3DiqWEqrm57g_nzQ%40mail.gmail.com. --0000000000008a92f105fa6bbb75 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You want `image.caption =3D 'image'`

Den fre 28 ap= r. 2023 17:25ThomasH <therch@gmail.c= om> skrev:
I want to ch= ange the alt=3D attribute of an image during translation. This is my Lua fi= lter:

function Image(elem)
=C2=A0 =C2=A0 nel= em =3D elem:clone()
=C2=A0 =C2=A0 nelem.attributes.alt =3D 'image= 9;
=C2=A0 =C2=A0 return nelem
end

It doe= sn't work, though. With HTML like

<?xml ver= sion=3D"1.0" encoding=3D"utf-8" ?>
<!DOCTYPE h= tml PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.= dtd">
<html>
<head>
</head>
<b= ody>
See image: <img src=3D"foo.jpg" alt=3D"foobar&= quot;/>
</body>
</html>

I get= an AST like this

[ Plain
=C2=A0 =C2=A0 [ Str &= quot;See"
=C2=A0 =C2=A0 , Space
=C2=A0 =C2=A0 , Str "image:= "
=C2=A0 =C2=A0 , Space
=C2=A0 =C2=A0 , Image
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 ( "" , [] , [ ( "alt" , "image"= ) ] )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 [ Str "foobar" ]
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 ( "foo.jpg" , "" )
=C2=A0 =C2= =A0 ]
]

I'm not sure how to interprete the = Image part, though. The Markdown output is:

See im= age: ![foobar](foo.jpg){alt=3D"image"}

<= /div>
which shows that the original alt text is retained, and the inten= ded replacement text is just added as if an arbitrary attribute.
=
What is wrong with my filter?

T= hanks, T.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0c93ede7-c= 24c-4a7f-ab8f-1b6b0d6aa7c1n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://gro= ups.google.com/d/msgid/pandoc-discuss/CADAJKhD1xpL-Re2M8tUQq8DiZNM%3DdXNw8t= Q%3DiqWEqrm57g_nzQ%40mail.gmail.com.
--0000000000008a92f105fa6bbb75--