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 nelem
end

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-/JYPxA39Uh5TLH3MbocFFw@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.