From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/25119 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: Colored text in PDF Date: Tue, 05 May 2020 13:58:59 -0700 Message-ID: References: <5f7aae6a-8087-439d-874b-dcf547dd10b1@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="35011"; mail-complaints-to="usenet@ciao.gmane.io" To: "R. Wils" , pandoc-discuss Original-X-From: pandoc-discuss+bncBCJZJHG45QDBBIFHY72QKGQEYFLFIWA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue May 05 22:59:16 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pg1-f188.google.com ([209.85.215.188]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jW4eq-00091F-Er for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 05 May 2020 22:59:16 +0200 Original-Received: by mail-pg1-f188.google.com with SMTP id w3sf1879676pgl.1 for ; Tue, 05 May 2020 13:59:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588712355; cv=pass; d=google.com; s=arc-20160816; b=WsLYNndzm7lJXBA4WNVVDdDIvn4pEC6IfiLsuZQLjAF6f1u1Wiz+KZdGytSQarJcvV SPU8IW8mChXgq338xG7qFNbS/HmlulAGD7XceeJh/ZOmYP2Zwfnd89SBnkeD1q4gSEPT ijQ9F6wIFGkAQuew7xhMVtDLMQaR//sUTpN2oIAJIoApUP6sFrRymRHsb24/69Ksst7o T02yphzx1Wd4O0hynw/u7Hadu3JtyJxeo2SOgyjr80lXR1ZcwSHlWoA3Hef/+/yyb8yq UqMazk3Gt7Z4iPy8IWQ6u15DVYC5ZKE4dCZGIpTDQ191u186jjXTPLs/I8LM+r17oaGD mKeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:mime-version:message-id :date:references:in-reply-to:subject:to:from:sender:dkim-signature; bh=upsIp4LNPoKfp71sh+td1ZETGvfIwiGutgUiE054ycE=; b=MH1zGQD2aUBwsJ0EIGUwLC3Ro7QdljUEEr+P/jYl/uKmtb9z/5Jh/y4UYJyYUQd5VB +ahVznvWOfnjg8FRWDkgm7i5gD7RXFMwa7aZf+FhDFyQremdK5I7pRZdIO5jNbfADeIA FmBnB14Fl/cbEkZBhwmFO96UKvsWXBXTwOLnJsmGNYWgXZXMq5RupboWQJrYPqbALA/r eNakWnz4yoC6ia2hg3qh8Fic7NUxRn3FOo0OHY7rdLPPofc9m9D9i1H8WIgFAbqgn8Vk OhqWRNZowW5ikwBHLS/IOeth2QpXnwvCB4CfjFFLQ5BJCBgUpGxpe7bpxpAD/bTeMvWB i0ag== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=TTZTIC5e; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::62c as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:subject:in-reply-to:references:date:message-id :mime-version:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=upsIp4LNPoKfp71sh+td1ZETGvfIwiGutgUiE054ycE=; b=bM1XKFwXMpGVSlwiJJHWS/LcqzRyUA8U4xfmKhWr941si32Lk58D6s8Yv0pF4E5pvX EuPJq+jD3DIQxTo9U1uhRfynJhdfzbqRAXCqckAvsuzUIoWg6T/WdQMo1nVjlqyZLIGD TRZIzGr+mCVk0o7+C9Ql55u0jMxxUQJQr5J65/u9xUpC8FKLnStT7ABhFCBNR2ownJlP /KhUMjVKtHl5tabR1RIaQgqSIWHi+oFTpqj0xeexBcxq+fY4DwDDmlBRKp+sZY0FlTlj zPhbXmsTrwWEunM7FwUcvuOKwnOJA+gSyjTiK4GV7Z+AjV6RiTj0NdEClh5k5r8zFT3B h7tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:subject:in-reply-to:references :date:message-id:mime-version:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=upsIp4LNPoKfp71sh+td1ZETGvfIwiGutgUiE054ycE=; b=Gl9y2/YOLJ7/k0Rl/BfFdL56a8k0bkBOMC00F7//UzCHNGj8Lt4uAecXAy2iY/hwrn BaUXLnfnAaiBITVLO2DuK2htJR9vphb0zL5v3evsS7jEdNWq6wfofTDFqBsiA6yfXocY JkM1hmlKLNyTaJvNGRwauCX5yACQmUsf0KJFPFAIi+tUsTloK1Gcs7kNj0yDt2+buuCl OPM9lYWcoAimmjwaz93rOfFoo9RL0blXwCD0eQP11fWI6qycYEa6TmDvIEpOhWHUcRXx IrfBflqKs7QKYZHVay+OOjqIBx1g62PEvRHrfxjAn11M5KwqtsDM5DlftJeNyZzevJps afyg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AGi0PuZDQzgKyUfq8AJmCpq0Xktw5uVV/zvNjhq6jb5A/56IkfzTNXn7 xu6rUuFCWImM0Rb1YACEL1E= X-Google-Smtp-Source: APiQypLhTU5U/Z+JdDe7q+/Fvg4rSMEKESEmBMFLFTPFb2UfyOLNEjo0fr2uQ5ImaAZKk0v+owA/Yg== X-Received: by 2002:a62:1c89:: with SMTP id c131mr4642939pfc.164.1588712355197; Tue, 05 May 2020 13:59:15 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a17:902:9a03:: with SMTP id v3ls794578plp.11.gmail; Tue, 05 May 2020 13:59:12 -0700 (PDT) X-Received: by 2002:a17:902:c487:: with SMTP id n7mr4728486plx.316.1588712352145; Tue, 05 May 2020 13:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588712352; cv=none; d=google.com; s=arc-20160816; b=zye1WlD0FvPOcWbxTRC8jNWmcs8T3yzDQ5eGNUCvhiAMt26PGmPfev1dvqvlL4djtW F5bQ+v/TDid7s5Hu2WeWedceQubPKuHEVBJaYOKyRrQfyS9yso6CFoJD5REG+5vxNUU0 ANAB/6Ne9ZATMYkDrq1aW4V+TZdCXVtlMTLA2vVSOdON0v1MDyB3RXBOaPUIVoIzmgUM whQ7PC3P/3q4qBBc8AB9r4i4L/0LmeCoVEHc3QrVWarHS6uPU2h0KD/vzCOKBYkc0N5D anorfxVdsQtK9KTYxvwkx2b/YJDxSGfkPJXtpSlSGruNnOaf2hgoiHoBufhuGhdZ2Enn VsJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :dkim-signature; bh=1HUbcsJPQip21lC06CiWNkYha1369Zt2hFJjX6NXhIs=; b=MZmtIOuzi+BqMIwbaW/W8Lnjny6ZMYPe+4ji/hl/7rO41tNuuTGEsHy0NZMhQhfew5 ENk0GEEbhojP9j5fAZ+tm0S6Q4YRhwhgoAuEAdKXP+dy+szPq8pjK5qJJRb8VSBH0d1G hylyArafiv0C2O8i7sqC34boDHXllVORgfUgu8L2/Ks8aGJR4WqDoBX8cw6VLZvSWQ5X eFgQerwMPpf0V4wz+iTxoDdA8kyJ8iYYRUVsNnMQzQJ5ser9X/IOM5UP2XdPl5+oxG1I /BQY8dfD0es1hvTe5JBOeKzvMQPeK9O9ASn9y/7QwHwzA/DBJNI2dzQBVmt9e86W8loF QOpw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=TTZTIC5e; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::62c as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Original-Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com. [2607:f8b0:4864:20::62c]) by gmr-mx.google.com with ESMTPS id a3si2974pfr.4.2020.05.05.13.59.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 May 2020 13:59:12 -0700 (PDT) Received-SPF: pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::62c as permitted sender) client-ip=2607:f8b0:4864:20::62c; Original-Received: by mail-pl1-x62c.google.com with SMTP id s10so63828plr.1 for ; Tue, 05 May 2020 13:59:12 -0700 (PDT) X-Received: by 2002:a17:90b:3444:: with SMTP id lj4mr5441233pjb.37.1588712351746; Tue, 05 May 2020 13:59:11 -0700 (PDT) Original-Received: from johnmacfarlane.net (li55-134.members.linode.com. [74.82.3.134]) by smtp.gmail.com with ESMTPSA id f136sm2737660pfa.59.2020.05.05.13.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 13:59:10 -0700 (PDT) Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id 34D7EA256; Tue, 5 May 2020 16:59:00 -0400 (EDT) In-Reply-To: X-Original-Sender: jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=TTZTIC5e; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::62c as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@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:25119 Archived-At: 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-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.