Yes, I've found the error. Thank you John for your help. The pandoc-discuss group is very helpful. On Wednesday, May 6, 2020 at 6:42:56 PM UTC+2, John MacFarlane wrote: > > > Probably attributes.text-decoration needs to be > attributes["text-decoration"] -- the hyphen is > interpreted as subtraction. > > "R. Wils" > writes: > > > Yes!! Thank you very much. > > > > It worked also converting to PDF (adding -o mydoc.pdf to the call with > > pandoc) > > > > 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? > > > > > > On Tuesday, May 5, 2020 at 10:59:17 PM UTC+2, John MacFarlane wrote: > >> > >> > >> Try this one: > >> > >> function Span(el) > >> if FORMAT == "latex" and el.attributes.color then > >> return { pandoc.RawInline("latex", "\\textcolor{" .. > >> el.attributes.color .. "}"), el } > >> end > >> end > >> > >> Call with pandoc --lua-filter my_luafilter.lua -t latex > >> > >> With input > >> > >> [this is my text]{color=red} > >> > >> (note = not :) you should get the right result. > >> > >> > >> "R. Wils" > writes: > >> > >> > Thank you very much for your reply. > >> > > >> > Pandoc is so nice but also very difficult to understand. > >> > I've never seen the lua language before. I'm quit familiar with > Python > >> and > >> > Html but I've never seen lua code before. > >> > > >> > I've read the pages: > >> > - lua-filters.html > >> > Created a file: my_luafilter.lua > >> > > >> > with your function inside > >> > > >> > function Span(el) > >> > if el.attributes.color then > >> > return { pandoc.rawInline("latex", "\\textcolor{" .. > >> > el.attributes.color .. "}"), el } > >> > end > >> > end > >> > > >> > And in my pandoc.markdown file I added this: > >> > > >> > test > >> > > >> > And added this filter to my pandoc command: > >> > --lua-filter=d:\\my_luafilter.lua > >> > > >> > Nothing happened. > >> > What did I wrong? > >> > > >> > Sorry to ask you all these questions > >> > I just need *colored text* and *underscore* for a markdown document I > >> > created and which I want to convert to PDF format. > >> > I'll learn every day a bit more about lua and lua filters. > >> > > >> > On Tuesday, May 5, 2020 at 6:15:06 PM UTC+2, John MacFarlane wrote: > >> >> > >> >> > >> >> Cleanest way is to use a Span with an attribute, plus a > >> >> lua filter that reacts to Spans with that attribute by > >> >> adding some LaTeX color commands. > >> >> > >> >> See the lua filter documentation and feel free to ask > >> >> if you have questions. > >> >> > >> >> Something like this (untested) > >> >> > >> >> function Span(el) > >> >> if el.attributes.color then > >> >> return { pandoc.rawInline("latex", "\\textcolor{" .. > >> >> el.attributes.color .. "}"), el } > >> >> end > >> >> end > >> >> > >> >> "R. Wils" > writes: > >> >> > >> >> > Does anyone know how to color text in a PDF > >> >> > (converting from a pandoc.markdown text file)? > >> >> > > >> >> > I tried to use a span and div tag without success. > >> >> > > >> >> > (Sorry I'm a new pandoc user) > >> >> > > >> >> > -- > >> >> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . > >> >> > To view this discussion on the web visit > >> >> > >> > https://groups.google.com/d/msgid/pandoc-discuss/5f7aae6a-8087-439d-874b-dcf547dd10b1%40googlegroups.com. > > >> > >> >> > >> >> > >> > > >> > -- > >> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . > >> > To view this discussion on the web visit > >> > https://groups.google.com/d/msgid/pandoc-discuss/d38ce0bc-44cc-4e70-9914-728835ead837%40googlegroups.com. > > >> > >> > > > > -- > > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . > > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/675c273d-a1c9-4e7a-8ec1-ec604ee056d7%40googlegroups.com. > > -- 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/c9600dba-b955-4f59-81da-c9646f9a55ad%40googlegroups.com.