Thanks Albert,

I changed it as you've indicated:

function Span(el)
  if FORMAT == "latex" and el.attributes.color then
    return { pandoc.RawInline("latex", "\\textcolor{" ..
  el.attributes.color .. "}"), el }
  elseif FORMAT == "latex" and el.attributes.['text-decoration'] then
    return { pandoc.RawInline("latex", "\\underline{" ..
  el.attributes.['text-decoration'] .. "}"), el }
  end
end

That gave another error:
my_luafilter.lua:5: <name> expected near '['

On Wednesday, May 6, 2020 at 11:48:41 AM UTC+2, Albert Krewinkel wrote:
R. Wils writes:

> I tried to add text underline to the same lua function;
>
> function Span(el)
>   if FORMAT == "latex" and el.attributes.color then
>     return { pandoc.RawInline("latex", "\\textcolor{" ..
>   el.attributes.color .. "}"), el }
>   elseif FORMAT == "latex" and el.attributes.text-decoration then
>     return { pandoc.RawInline("latex", "\\underline{" ..
>   el.attributes.text-decoration .. "}"), el }
>   end
> end
>
> with input
> [this is my text]{text-decoration=underline}
>
> This gives an error `my_luafilter.lua:5: attempt to perform arithmetic on a
> nil value (field 'text')`
> What did I wrong?

The issue is with `el.attributes.text-decoration`. Minus/hyphens are
special in Lua, so Lua treats this as "substract `decoration` from
`el.attributes.text`. The solution is to use more explicit table-access
syntax: `el.attributes['text-decoration']`.


--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124

--
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/991d4847-878c-4ca9-af50-1008e701d9bd%40googlegroups.com.