public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: "R. Wils" <raiwil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Colored text in PDF
Date: Wed, 6 May 2020 03:16:46 -0700 (PDT)	[thread overview]
Message-ID: <991d4847-878c-4ca9-af50-1008e701d9bd@googlegroups.com> (raw)
In-Reply-To: <87v9l9xukv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 2003 bytes --]

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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.

[-- Attachment #1.2: Type: text/html, Size: 2934 bytes --]

  parent reply	other threads:[~2020-05-06 10:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 14:36 R. Wils
     [not found] ` <5f7aae6a-8087-439d-874b-dcf547dd10b1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-05-05 16:14   ` John MacFarlane
     [not found]     ` <m2o8r24avd.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-05-05 17:36       ` R. Wils
     [not found]         ` <d38ce0bc-44cc-4e70-9914-728835ead837-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-05-05 18:00           ` Pablo Rodríguez
2020-05-05 20:58           ` John MacFarlane
     [not found]             ` <m2o8r2m73g.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-05-06  9:00               ` R. Wils
     [not found]                 ` <675c273d-a1c9-4e7a-8ec1-ec604ee056d7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-05-06  9:48                   ` Albert Krewinkel
     [not found]                     ` <87v9l9xukv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-05-06 10:16                       ` R. Wils [this message]
2020-05-06 16:42                   ` John MacFarlane
     [not found]                     ` <m2tv0tkoao.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-05-06 17:52                       ` R. Wils
2020-05-06 10:24   ` R. Wils
     [not found]     ` <d3523f75-4ff6-455f-a5f7-d177cf048486-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-05-06 10:38       ` Albert Krewinkel
     [not found]         ` <87tv0txsa3.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-05-06 12:29           ` R. Wils
2020-05-06 12:28   ` R. Wils
2020-05-06 13:51   ` R. Wils
     [not found]     ` <03334be3-9d8c-4834-a0f1-e623ef668f42-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-05-06 14:18       ` Jeremy Theler
     [not found]         ` <443fca3d3f7aec7a51ddb5b7efad86c0b3958b00.camel-24em0bpozeFWk0Htik3J/w@public.gmane.org>
2020-05-06 15:12           ` R. Wils
     [not found]             ` <23108add-70bd-42e1-a320-8c5a38363b6f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-05-06 16:40               ` jeremy theler
     [not found]                 ` <CAK0LiymWf-favbZ6t4VWrqW5CkpLRFvjd8096h9RSL3_7nxvoA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-05-06 17:51                   ` R. Wils
2020-05-14  8:20   ` Christophe Demko

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=991d4847-878c-4ca9-af50-1008e701d9bd@googlegroups.com \
    --to=raiwil-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).