public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Colored text in PDF
@ 2020-05-05 14:36 R. Wils
       [not found] ` <5f7aae6a-8087-439d-874b-dcf547dd10b1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 20+ messages in thread
From: R. Wils @ 2020-05-05 14:36 UTC (permalink / raw)
  To: pandoc-discuss


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

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

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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-06 10:24   ` R. Wils
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: John MacFarlane @ 2020-05-05 16:14 UTC (permalink / raw)
  To: R. Wils, pandoc-discuss


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" <raiwil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: R. Wils @ 2020-05-05 17:36 UTC (permalink / raw)
  To: pandoc-discuss


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

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:

<span style="color:red">test</span>

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" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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 <javascript:>. 
> > 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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
  1 sibling, 0 replies; 20+ messages in thread
From: Pablo Rodríguez @ 2020-05-05 18:00 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On 5/5/20 7:36 PM, R. Wils wrote:
> [...]
> And in my pandoc.markdown file I added this:
>
> <span style="color:red">test</span>
>
> And added this filter to my pandoc command:
> --lua-filter=d:\\my_luafilter.lua
>
> Nothing happened.
> What did I wrong?

I think your Markdown source has to read:

  <span color="red">test</span>

Or even better:

  [test]{color="red"}

Just in case it helps,

Pablo
--
http://www.ousia.tk


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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>
  1 sibling, 1 reply; 20+ messages in thread
From: John MacFarlane @ 2020-05-05 20:58 UTC (permalink / raw)
  To: R. Wils, pandoc-discuss


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" <raiwil-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 
> 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:
>
> <span style="color:red">test</span>
>
> 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" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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 <javascript:>. 
>> > 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: R. Wils @ 2020-05-06  9:00 UTC (permalink / raw)
  To: pandoc-discuss


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

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" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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: 
> > 
> > <span style="color:red">test</span> 
> > 
> > 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" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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 <javascript:>. 
> >> > 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 <javascript:>. 
> > 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.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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 16:42                   ` John MacFarlane
  1 sibling, 1 reply; 20+ messages in thread
From: Albert Krewinkel @ 2020-05-06  9:48 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [not found]                     ` <87v9l9xukv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2020-05-06 10:16                       ` R. Wils
  0 siblings, 0 replies; 20+ messages in thread
From: R. Wils @ 2020-05-06 10:16 UTC (permalink / raw)
  To: pandoc-discuss


[-- 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 --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [not found] ` <5f7aae6a-8087-439d-874b-dcf547dd10b1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-05-05 16:14   ` John MacFarlane
@ 2020-05-06 10:24   ` R. Wils
       [not found]     ` <d3523f75-4ff6-455f-a5f7-d177cf048486-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-05-06 12:28   ` R. Wils
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: R. Wils @ 2020-05-06 10:24 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks Albert,

Yes it works.

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 

But something is strange:

Input:

[this is my text]{color=red}   
[this is my text]{text-decoration=underline} 

Output:
this is my text
*underline*this is my text

It underlines the word underline! 
Is my input wrong?


On Tuesday, May 5, 2020 at 4:36:51 PM UTC+2, R. Wils wrote:
>
> 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d3523f75-4ff6-455f-a5f7-d177cf048486%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: Albert Krewinkel @ 2020-05-06 10:38 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

R. Wils writes:

> 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 
>
> But something is strange:
>
> Input:
>
> [this is my text]{color=red}   
> [this is my text]{text-decoration=underline} 
>
> Output:
> this is my text
> *underline*this is my text
>
> It underlines the word underline! 
> Is my input wrong?

The input is fine, but the filter should be

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

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


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [not found] ` <5f7aae6a-8087-439d-874b-dcf547dd10b1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-05-05 16:14   ` John MacFarlane
  2020-05-06 10:24   ` R. Wils
@ 2020-05-06 12:28   ` R. Wils
  2020-05-06 13:51   ` R. Wils
  2020-05-14  8:20   ` Christophe Demko
  4 siblings, 0 replies; 20+ messages in thread
From: R. Wils @ 2020-05-06 12:28 UTC (permalink / raw)
  To: pandoc-discuss


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

Thank you.
Impressive Pandoc together with lua scripts. Never thought this was 
possible with markdown.
I really like it.

Next thing I want to do is to add text-align in the same function.
We need a double tag isn't it?
\begin{center} and \end{center}

Are there no default lua formatting scripts already available for download 
on the internet


On Tuesday, May 5, 2020 at 4:36:51 PM UTC+2, R. Wils wrote:
>
> 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e7070622-1f2d-4039-a1d3-1ad14115beef%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [not found]         ` <87tv0txsa3.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2020-05-06 12:29           ` R. Wils
  0 siblings, 0 replies; 20+ messages in thread
From: R. Wils @ 2020-05-06 12:29 UTC (permalink / raw)
  To: pandoc-discuss


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

 Thank you.
Impressive Pandoc together with lua scripts. Never thought this was 
possible with markdown.
I really like it.

Next thing I want to do is to add text-align in the same function.
We need a double tag isn't it?
\begin{center} and \end{center}

Are there no default lua formatting scripts already available for download 
on the internet?

On Wednesday, May 6, 2020 at 12:38:22 PM UTC+2, Albert Krewinkel wrote:
>
> R. Wils writes: 
>
> > 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 
> > 
> > But something is strange: 
> > 
> > Input: 
> > 
> > [this is my text]{color=red}   
> > [this is my text]{text-decoration=underline} 
> > 
> > Output: 
> > this is my text 
> > *underline*this is my text 
> > 
> > It underlines the word underline! 
> > Is my input wrong? 
>
> The input is fine, but the filter should be 
>
>     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} 
>       end 
>     end 
>
> -- 
> 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/cdf784a3-3f01-4a4b-b26f-a35484d91a39%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [not found] ` <5f7aae6a-8087-439d-874b-dcf547dd10b1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
                     ` (2 preceding siblings ...)
  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-14  8:20   ` Christophe Demko
  4 siblings, 1 reply; 20+ messages in thread
From: R. Wils @ 2020-05-06 13:51 UTC (permalink / raw)
  To: pandoc-discuss


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

 I found out that 
\textcolor{red} does work as well (without lua script).
What is the difference between:

\textcolor{red}{This is my text}
[This is my text]{color=red}
??

I noted that the markdown signs *,**,#,## .... can be used if I use [This 
is my text]{color=red}

-- 
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/03334be3-9d8c-4834-a0f1-e623ef668f42%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: Jeremy Theler @ 2020-05-06 14:18 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On Wed, 2020-05-06 at 06:51 -0700, R. Wils wrote:
>  I found out that 
> \textcolor{red} does work as well (without lua script).
> What is the difference between:
> 
> \textcolor{red}{This is my text}
> [This is my text]{color=red}
> ??

The former is native LaTeX and the latter is Pandoc's markdown.

> 
> I noted that the markdown signs *,**,#,## .... can be used if I use
> [This is my text]{color=red}

yes, in native LaTeX the # is a special character.


--
jeremy theler
www.seamplex.com


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: R. Wils @ 2020-05-06 15:12 UTC (permalink / raw)
  To: pandoc-discuss


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

Isn't it easier to write my text documents directly in Latex (.tex?) and 
convert it with pandoc to pdf?
What are other people using?

Now I'm writing my text documents in Markdown format (.md), include a few 
latex commands and convert it to pdf (using pandoc) 

markdown format is more readable but it is easier to add latex code.

ps: I didn't know that I could do so many things with Pandoc. 

-- 
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/23108add-70bd-42e1-a320-8c5a38363b6f%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: jeremy theler @ 2020-05-06 16:40 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1849 bytes --]

That would be an overkill. If you want to go from .tex to .pdf use old
plain LaTeX and leave pandoc aside.

Regarding what other people use, that would depend on what these other
people need and/or want. For instance, my usual workflow is to write in
Pandoc's markdown to get pdf, html, epub and sometimes texinfo.

--
jeremy theler
www.seamplex.com

On Wed, May 6, 2020, 12:12 R. Wils <raiwil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Isn't it easier to write my text documents directly in Latex (.tex?) and
> convert it with pandoc to pdf?
> What are other people using?
>
> Now I'm writing my text documents in Markdown format (.md), include a few
> latex commands and convert it to pdf (using pandoc)
>
> markdown format is more readable but it is easier to add latex code.
>
> ps: I didn't know that I could do so many things with Pandoc.
>
> --
> 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/23108add-70bd-42e1-a320-8c5a38363b6f%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/23108add-70bd-42e1-a320-8c5a38363b6f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAK0LiymWf-favbZ6t4VWrqW5CkpLRFvjd8096h9RSL3_7nxvoA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 2932 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [not found]                 ` <675c273d-a1c9-4e7a-8ec1-ec604ee056d7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-05-06  9:48                   ` Albert Krewinkel
@ 2020-05-06 16:42                   ` John MacFarlane
       [not found]                     ` <m2tv0tkoao.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  1 sibling, 1 reply; 20+ messages in thread
From: John MacFarlane @ 2020-05-06 16:42 UTC (permalink / raw)
  To: R. Wils, pandoc-discuss


Probably attributes.text-decoration needs to be
attributes["text-decoration"] -- the hyphen is
interpreted as subtraction.

"R. Wils" <raiwil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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: 
>> > 
>> > <span style="color:red">test</span> 
>> > 
>> > 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" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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 <javascript:>. 
>> >> > 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 <javascript:>. 
>> > 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.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [not found]                 ` <CAK0LiymWf-favbZ6t4VWrqW5CkpLRFvjd8096h9RSL3_7nxvoA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-05-06 17:51                   ` R. Wils
  0 siblings, 0 replies; 20+ messages in thread
From: R. Wils @ 2020-05-06 17:51 UTC (permalink / raw)
  To: pandoc-discuss


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

Yes, you're right.
I checked Latex today but it's not easy to read.
I'll go on using markdown and will put a few latex commands in the text.

Thank you all for your help.

On Wednesday, May 6, 2020 at 6:40:32 PM UTC+2, Jeremy Theler wrote:
>
> That would be an overkill. If you want to go from .tex to .pdf use old 
> plain LaTeX and leave pandoc aside.
>
> Regarding what other people use, that would depend on what these other 
> people need and/or want. For instance, my usual workflow is to write in 
> Pandoc's markdown to get pdf, html, epub and sometimes texinfo.
>
> --
> jeremy theler
> www.seamplex.com
>
> On Wed, May 6, 2020, 12:12 R. Wils <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> wrote:
>
>> Isn't it easier to write my text documents directly in Latex (.tex?) and 
>> convert it with pandoc to pdf?
>> What are other people using?
>>
>> Now I'm writing my text documents in Markdown format (.md), include a few 
>> latex commands and convert it to pdf (using pandoc) 
>>
>> markdown format is more readable but it is easier to add latex code.
>>
>> ps: I didn't know that I could do so many things with Pandoc. 
>>
>> -- 
>> 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 <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/23108add-70bd-42e1-a320-8c5a38363b6f%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/23108add-70bd-42e1-a320-8c5a38363b6f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/e2e55eed-7255-49d5-a70f-2cb046ef1ae0%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [not found]                     ` <m2tv0tkoao.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-05-06 17:52                       ` R. Wils
  0 siblings, 0 replies; 20+ messages in thread
From: R. Wils @ 2020-05-06 17:52 UTC (permalink / raw)
  To: pandoc-discuss


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

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" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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: 
> >> > 
> >> > <span style="color:red">test</span> 
> >> > 
> >> > 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" <rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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 <javascript:>. 
> >> >> > 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 <javascript:>. 
> >> > 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 <javascript:>. 
> > 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.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Colored text in PDF
       [not found] ` <5f7aae6a-8087-439d-874b-dcf547dd10b1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
                     ` (3 preceding siblings ...)
  2020-05-06 13:51   ` R. Wils
@ 2020-05-14  8:20   ` Christophe Demko
  4 siblings, 0 replies; 20+ messages in thread
From: Christophe Demko @ 2020-05-14  8:20 UTC (permalink / raw)
  To: pandoc-discuss


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

I've published the pandoc-latex-color filter 
https://pypi.org/project/pandoc-latex-color/

Le mardi 5 mai 2020 16:36:51 UTC+2, R. Wils a écrit :
>
> 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/dde498a2-f696-4127-992b-ae91ae789e72%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2020-05-14  8:20 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 14:36 Colored text in PDF 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
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

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).