From: BPJ <bpj-J3H7GcXPSITLoDKTGw+V6w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Lua Filter: Change image alt= attribute
Date: Fri, 28 Apr 2023 22:58:07 +0200 [thread overview]
Message-ID: <CADAJKhD1xpL-Re2M8tUQq8DiZNM=dXNw8tQ=iqWEqrm57g_nzQ@mail.gmail.com> (raw)
In-Reply-To: <0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2210 bytes --]
You want `image.caption = 'image'`
Den fre 28 apr. 2023 17:25ThomasH <therch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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
>
> <?xml version="1.0" encoding="utf-8" ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html>
> <head>
> </head>
> <body>
> See image: <img src="foo.jpg" alt="foobar"/>
> </body>
> </html>
>
> 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
> <https://groups.google.com/d/msgid/pandoc-discuss/0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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.
[-- Attachment #2: Type: text/html, Size: 3571 bytes --]
next prev parent reply other threads:[~2023-04-28 20:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-28 15:24 ThomasH
[not found] ` <0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-04-28 20:58 ` BPJ [this message]
[not found] ` <CADAJKhD1xpL-Re2M8tUQq8DiZNM=dXNw8tQ=iqWEqrm57g_nzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-04-29 16:32 ` ThomasH
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='CADAJKhD1xpL-Re2M8tUQq8DiZNM=dXNw8tQ=iqWEqrm57g_nzQ@mail.gmail.com' \
--to=bpj-j3h7gcxpsitlodktgw+v6w@public.gmane.org \
--cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
/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).