From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/25125 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "R. Wils" Newsgroups: gmane.text.pandoc Subject: Re: Colored text in PDF Date: Wed, 6 May 2020 02:00:44 -0700 (PDT) Message-ID: <675c273d-a1c9-4e7a-8ec1-ec604ee056d7@googlegroups.com> References: <5f7aae6a-8087-439d-874b-dcf547dd10b1@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_31_1480316958.1588755644373" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="27671"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCUYVKWP6AMBBPPZZH2QKGQENP4FZHA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed May 06 11:00:52 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oi1-f188.google.com ([209.85.167.188]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jWFv6-00074I-KR for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 06 May 2020 11:00:48 +0200 Original-Received: by mail-oi1-f188.google.com with SMTP id j84sf970851oib.21 for ; Wed, 06 May 2020 02:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=rWVHroWs4tkYW+ZvAIIYG0P+Zt67r46ZczSr7tu/qM4=; b=P0Oow/UnXLkY8g+Yvcq/K3XYyOSFcnpDfQIOVwznO3wI++rXnA9sM5HQcbMxwiMe0B 4MGL6D4nSE+iEOTUBoD+L5SMqp8M+wYJJiHFmo3ctkmaA2mgBAratD2bCepSrb08IDTu NEplfE2ZlDS3Lj7p24daBPtZ54ygdCZ7JCs9HPiNsapOqYBPhLwltlzcLHBJDRY36bw6 VdSp1abwKQ9T2zk+4Whvf1852gc7JtZEk31ncMlEgqPZeJJHwp4cmXjLV+222TxQy7I+ ohHEvZl89wTth0tCQRQEvSDErKkbryOANzRU8XV94ZG3xkaFMvLEJv7EoxaKi+h28Lj1 NspQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=rWVHroWs4tkYW+ZvAIIYG0P+Zt67r46ZczSr7tu/qM4=; b=hSIK02TZxI3eUzhhal6Zh7h0pCbugGTWKjF7UJNxwl2EFzX8zDpVVZdZvAyCKNcqMy fgLGE5OedHqYPjj/ZwACrHsA0TYnlXvNdhaducVjEKXPosh3WmQOdR4sf9hnsXOiUOag Bx85gckdwKuvZ8nPtBUV85Q1KeCo+6HXOX/yH2sGxv0OkC5KSqqFbpLmyDo+OjnfiLmR N5/p5Q3wpXsAZVAAPJNt9QRvfOjEdQjHQbdQOjZ9kXdpuI/It+khylYZ1ON2mgajFWpi sSBpXs4l+vREip5p9mRYbPZN2z8GiW8SLFK96+YtoUfjHtxl4n7PQrgGT8cZuBxaVQyl AKAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=rWVHroWs4tkYW+ZvAIIYG0P+Zt67r46ZczSr7tu/qM4=; b=pYCs680SPapUehDxMGrPY3o0dda+9RMYS4HDtK8vf05wZ5wjfjz6sIlPKjwfrBccRk j9kHME4gowmIMVzFFKJ8KnPMAmMmWokR2obA5V0TNDvn88+aeGXENH9cv9L4z8CZyHfq r0tFG/5sZs3s/MBor+fFVuh45l26503TtPkVMzAhPgsyf49auDDiRXoYDGtcF0Hu6CnI vIGqHMg1VaN1VfGQzeb6Scr6LhkCqc81YV4V1lpJ685xbclyf/0kPq1fVmnLKpXb3N6s ZYGkgx9M2YQxxIQjPauXSjRaggmN+EUqY/XeH3MO6ZipilPdgy0Iprh/MKtl/nhlpIUP 0fNw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AGi0PuawS/MuQAcl4Y9pqq1ra81qQkc/yAUxEh5yrTlxef961yl4+GDn zjcpPLdfjguf1dGpBVutbx8= X-Google-Smtp-Source: APiQypIXmu5TyaKRGb7k/om2fSwNNdspUDHOVhEQqg4lXpW+IKlu9Iyi2hiZbpHtVgEonQ2EgqsV0A== X-Received: by 2002:a9d:5e04:: with SMTP id d4mr5925447oti.312.1588755647598; Wed, 06 May 2020 02:00:47 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6830:241c:: with SMTP id j28ls258869ots.1.gmail; Wed, 06 May 2020 02:00:45 -0700 (PDT) X-Received: by 2002:a9d:4f04:: with SMTP id d4mr5287463otl.271.1588755645028; Wed, 06 May 2020 02:00:45 -0700 (PDT) In-Reply-To: X-Original-Sender: raiwil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:25125 Archived-At: ------=_Part_31_1480316958.1588755644373 Content-Type: multipart/alternative; boundary="----=_Part_32_1917380566.1588755644374" ------=_Part_32_1917380566.1588755644374 Content-Type: text/plain; charset="UTF-8" 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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. ------=_Part_32_1917380566.1588755644374 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Yes!! Thank you very much.

I= t worked also converting to PDF (adding -o mydoc.pdf to the call with pando= c)

I tried to add text underline to the same lua f= unction;

function Span(el)
=C2=A0 if FORMAT =3D= =3D "latex" and el.attributes.color then
=C2=A0=C2=A0=C2=A0 re= turn { pandoc.RawInline("latex", "\\textcolor{" ..
= =C2=A0 el.attributes.color .. "}"), el }
=C2=A0 elseif FORMAT = =3D=3D "latex" and el.attributes.text-decoration then
=C2=A0= =C2=A0=C2=A0 return { pandoc.RawInline("latex", "\\underline= {" ..
=C2=A0 el.attributes.text-decoration .. "}"), el }<= br>=C2=A0 end
end

with input
[this is my text]{text-decoration=3Dunderline}

This gives an error `my_luafilter.lua:5: attempt to perform arithmetic o= n a nil value (field 'text')`
What did I wrong?
=


On Tuesday, May 5, 2020 at 10:59:17 PM UTC+2, John MacFa= rlane wrote:

Try this one:

function Span(el)=20
=C2=A0 if FORMAT =3D=3D "latex" and el.attributes.color then= =20
=C2=A0 =C2=A0 return { pandoc.RawInline("latex", "\\text= color{" ..=20
=C2=A0 el.attributes.color .. "}"), el }=20
=C2=A0 end=20
end=20

Call with pandoc --lua-filter my_luafilter.lua -t latex

With input

[this is my text]{color=3Dred}

(note =3D not :) you should get the right result.


"R. Wils" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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=20
> 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)=20
> =C2=A0 if el.attributes.color then=20
> =C2=A0 =C2=A0 return { pandoc.rawInline("latex", "\= \textcolor{" ..=20
> =C2=A0 el.attributes.color .. "}"), el }=20
> =C2=A0 end=20
> end=20
>
> And in my pandoc.markdown file I added this:
>
> <span style=3D"color:red">test</span>
>
> And added this filter to my pandoc command:
> --lua-filter=3Dd:\\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 documen= t I=20
> 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=20
>> lua filter that reacts to Spans with that attribute by=20
>> adding some LaTeX color commands.=20
>>
>> See the lua filter documentation and feel free to ask=20
>> if you have questions.=20
>>
>> Something like this (untested)=20
>>
>> function Span(el)=20
>> =C2=A0 if el.attributes.color then=20
>> =C2=A0 =C2=A0 return { pandoc.rawInline("latex", &qu= ot;\\textcolor{" ..=20
>> =C2=A0 el.attributes.color .. "}"), el }=20
>> =C2=A0 end=20
>> end=20
>>
>> "R. Wils" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript= :>> writes:=20
>>
>> > Does anyone know how to color text in a PDF=20
>> > (converting from a pandoc.markdown text file)?=20
>> >=20
>> > I tried to use a span and div tag without success.=20
>> >=20
>> > (Sorry I'm a new pandoc user)=20
>> >=20
>> > --=20
>> > You received this message because you are subscribed to t= he Google=20
>> Groups "pandoc-discuss" group.=20
>> > To unsubscribe from this group and stop receiving emails = from it, send=20
>> an email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:= >.=20
>> > To view this discussion on the web visit=20
>> https://groups.google.com/d/msgid/pandoc-discus= s/5f7aae6a-8087-439d-874b-dcf547dd10b1%40googlegroups.com.=20
>>
>>
>
> --=20
> 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-...@googlegroups.com.
> To view this discussion on the web visit https://groups.= google.com/d/msgid/pandoc-discuss/d38ce0bc-44cc-4e70-9914-728835e= ad837%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/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.co= m.
------=_Part_32_1917380566.1588755644374-- ------=_Part_31_1480316958.1588755644373--