From: ThomasH <therch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Lua Filter: Change image alt= attribute
Date: Fri, 28 Apr 2023 08:24:38 -0700 (PDT) [thread overview]
Message-ID: <0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n@googlegroups.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1414 bytes --]
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.
[-- Attachment #1.2: Type: text/html, Size: 2187 bytes --]
next reply other threads:[~2023-04-28 15:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-28 15:24 ThomasH [this message]
[not found] ` <0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-04-28 20:58 ` BPJ
[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=0c93ede7-c24c-4a7f-ab8f-1b6b0d6aa7c1n@googlegroups.com \
--to=therch-re5jqeeqqe8avxtiumwx3w@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).