From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32510 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: ThomasH Newsgroups: gmane.text.pandoc Subject: Re: Lua Filter: Change image alt= attribute Date: Sat, 29 Apr 2023 09:32:50 -0700 (PDT) Message-ID: <6b329ca9-dc71-488d-bbcf-8d8dea3c67fan@googlegroups.com> References: <0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_4932_1200474609.1682785970972" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34962"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCOJJAXZ7EPBBNENWWRAMGQEJTWWBCQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Apr 29 18:32:55 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f59.google.com ([209.85.160.59]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1psnVH-0008sU-Cx for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 29 Apr 2023 18:32:55 +0200 Original-Received: by mail-oa1-f59.google.com with SMTP id 586e51a60fabf-1877e4dff8asf668816fac.2 for ; Sat, 29 Apr 2023 09:32:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1682785974; x=1685377974; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=9A1iiCziTyDpy6k2Eled6W8Fiwmf7xHvwGN4kJ49WqQ=; b=YFf+/vPfMPvqtMco2fWjB+WN6il+TYaXfQ0FUXWV1LaQrhyvNZwjazgW8yAsqaTDTI TC5FATBLNBOCkwJ7GEp0Gg+uyVhGmbS+EhL7gn62IXMQLlcJZGxpCnQh2wk1G92rBqhz sVDlTbMRwcumEWOPGIRdwND/82SrCmIDznpyWWtA65D0KOduuTIa2yeudxkpU8z4C6c7 01Dk0mEJBPvI+uEJmVIhrQa+pENNCe5VNAZm1ugfdK24o8DR2lRr4nM6ZuxCp0pKrqlU niiTlkVTsO4hw+97psPsLU/guDM6SqnFRMSjJeJDEDP9ZTVpfVgEPyigvlEXdi5ku7Tu Lf4A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682785974; x=1685377974; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=9A1iiCziTyDpy6k2Eled6W8Fiwmf7xHvwGN4kJ49WqQ=; b=RyTx4Py/Is/UwB7yQppBjyuEGmfqtJHA5ZQM+rpnOEuJYNCt8DR34WCakgk/TibEQI 4EncsRnStUUDQ+Y3vWRMWJF6cOK5vkqo3VWny4qh4qoUUGm+PqVyOnpEYjWUTgyJfvAj ZwPn6ZigjKuAs+/Oxo8kjBipTmt9kd+FLYmHd5vxfxI1oFP1CDvUuUcEk8sEd9YL6hxb tGKcK9BdxXbMZEAW5EaNhu0sqWZAMqzmqhQ+t8Ijrtn23LYHxeDjBreBNLmRLSpmOapM dqyxlDn5c/S4Xh/CF9XDUJVW/UtYr0lzshTkWAyHAV6Xcq5pHeP8lyInE4Dk8ommwmTI C2GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682785974; x=1685377974; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=9A1iiCziTyDpy6k2Eled6W8Fiwmf7xHvwGN4kJ49WqQ=; b=JzyRXJMzsfoN+IKTRi0iqqCFU0JqTdsPPBTW2W1m1yAgo1KaOn8ery2TEbBmjP+XXC mcUgxp4RSGVSZnyI2hNAnyu9ucx7iU7yAv2IR//itwXFlOfXxDAcm0hAA2G6k92ekcBb U034wwxYL57XCLUOwEhjK1+H2KbvkRNM6P5VW6hK+BSGD/VWDD8/f8UY2fnxPhvLaOea 6lI/BVXlmhgSgJS1kYSmh89eKPQuobDt90Z+PtVoMN4Dx042mx5t8+G6i75LvIAKdVdu vh2jvqogaXGE1O59JYcmFBYHu95sTlNP3KUkRN6InWhjtg21Px Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDzFLTifGmN8QDJAnazzn91qwXErc9xtYm/YzSkf+4czAau30vso 0eHUZY77wEdtUGuQQiqA3GM= X-Google-Smtp-Source: ACHHUZ6pFWxvtNSf2NsPpiyzGIoXfrXQIldPjcdsCsYV+LI0MIVjRj7CspSVgtsJElnSU2qBZrsh/g== X-Received: by 2002:a05:6870:d7a5:b0:187:d96b:5df3 with SMTP id bd37-20020a056870d7a500b00187d96b5df3mr3106272oab.2.1682785974086; Sat, 29 Apr 2023 09:32:54 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6830:3987:b0:6a5:e8ad:7437 with SMTP id bs7-20020a056830398700b006a5e8ad7437ls1200067otb.9.-pod-prod-gmail; Sat, 29 Apr 2023 09:32:51 -0700 (PDT) X-Received: by 2002:a9d:7dd2:0:b0:6a7:bdef:16a8 with SMTP id k18-20020a9d7dd2000000b006a7bdef16a8mr2173951otn.4.1682785971579; Sat, 29 Apr 2023 09:32:51 -0700 (PDT) In-Reply-To: X-Original-Sender: therch-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:32510 Archived-At: ------=_Part_4932_1200474609.1682785970972 Content-Type: multipart/alternative; boundary="----=_Part_4933_1323166581.1682785970972" ------=_Part_4933_1323166581.1682785970972 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Great, that did it! T. On Friday, April 28, 2023 at 10:58:23=E2=80=AFPM UTC+2 BPJ wrote: > You want `image.caption =3D 'image'` > > Den fre 28 apr. 2023 17:25ThomasH skrev: > >> I want to change the alt=3D attribute of an image during translation. Th= is=20 >> is my Lua filter: >> >> >> >> >> >> *function Image(elem) nelem =3D elem:clone() nelem.attributes.alt = =3D=20 >> 'image' return nelemend* >> >> It doesn't work, though. With HTML like >> >> >> > http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >> >> >> >> >> See image: 3D"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=20 >> output is: >> >> See image: ![foobar](foo.jpg){alt=3D"image"} >> >> which shows that the original alt text is retained, and the intended=20 >> replacement text is just added as if an arbitrary attribute. >> >> What is wrong with my filter? >> >> Thanks, T. >> >> --=20 >> You received this message because you are subscribed to the Google Group= s=20 >> "pandoc-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send a= n=20 >> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit=20 >> https://groups.google.com/d/msgid/pandoc-discuss/0c93ede7-c24c-4a7f-ab8f= -1b6b0d6aa7c1n%40googlegroups.com=20 >> >> . >> > --=20 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 e= mail 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/6b329ca9-dc71-488d-bbcf-8d8dea3c67fan%40googlegroups.com. ------=_Part_4933_1323166581.1682785970972 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Great, that did it!

T.

On Friday, A= pril 28, 2023 at 10:58:23=E2=80=AFPM UTC+2 BPJ wrote:
You want `image.= caption =3D 'image'`

Den fre 28 apr= . 2023 17:25ThomasH <the...@g= mail.com> skrev:
I want to change the alt=3D attribute of an imag= e during translation. This is my Lua filter:

fu= nction Image(elem)
=C2=A0 =C2=A0 nelem =3D elem:clone()
=C2=A0 =C2=A0= nelem.attributes.alt =3D 'image'
=C2=A0 =C2=A0 return nelem
= end

It doesn't work, though. With HTML lik= e

<?xml version=3D"1.0" encoding=3D&q= uot;utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1= .0 Transitional//EN" "http://www.w3.org/TR= /xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<he= ad>
</head>
<body>
See image: <img src=3D"f= oo.jpg" alt=3D"foobar"/>
</body>
</html>= ;

I get an AST like this

= [ Plain
=C2=A0 =C2=A0 [ Str "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 ( "" , [] , [ ( &qu= ot;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 n= ot sure how to interprete the Image part, though. The Markdown output is:

See image: ![foobar](foo.jpg){alt=3D"image&quo= t;}

which shows that the original alt t= ext is retained, and the intended replacement text is just added as if an a= rbitrary attribute.

What is wrong with my filter?<= br>

Thanks, 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-discus= ...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0= c93ede7-c24c-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://groups.google.com/d= /msgid/pandoc-discuss/6b329ca9-dc71-488d-bbcf-8d8dea3c67fan%40googlegroups.= com.
------=_Part_4933_1323166581.1682785970972-- ------=_Part_4932_1200474609.1682785970972--