From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/4938 Path: news.gmane.org!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: Making a simple script to send coloured output to a terminal. Date: Sun, 21 Oct 2012 08:18:31 -0700 Message-ID: <20121021151831.GB30752@Johns-MacBook-Pro.local> References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1350832711 30114 80.91.229.3 (21 Oct 2012 15:18:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 21 Oct 2012 15:18:31 +0000 (UTC) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDW7ZIEHTIIBBRNESCCAKGQE6FG4ISY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Oct 21 17:18:39 2012 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-ob0-f186.google.com ([209.85.214.186]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TPxIT-0000pz-Nv for gtp-pandoc-discuss@m.gmane.org; Sun, 21 Oct 2012 17:18:38 +0200 Original-Received: by mail-ob0-f186.google.com with SMTP id eq6sf1847711obc.3 for ; Sun, 21 Oct 2012 08:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-beenthere:received-spf:date:from:to:subject:message-id:references :mime-version:in-reply-to:x-pgp-key:user-agent:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type:content-disposition; bh=f+Udl3a/vrhI72kKxt4Iqug+Ug/lSN6m831/aY9ZB2I=; b=qAIUz4nB8DIJR4n3AfrFerVL8Ody6QwC9kpcvg7/iS7QnyxTXOyElOkbw+SmvUHhbT s5aEe3btP5eYFIiyDPogd/V0wcLo5+i+0NxIyfDSeaypRmqYMSPSVf+h1rcxH6rIIcaM fboUT/LNqsbz1uGbw7tdznf7tXTz/ucAod67pWlu10assxDGtoTDLzSjcBF0Ee+GZ8OJ Z+m7bbGKuFFa5LlxsH1dpApmsKH5YblZJShIWqCgqkqh2AxMvOXyLWFxdI59l0jHYlVX 4LbC2IHxpXejYy3h3t40i2li0SGzq2Pnxw9nyJ0X+PJjhRfr Original-Received: by 10.68.242.74 with SMTP id wo10mr1858489pbc.9.1350832709416; Sun, 21 Oct 2012 08:18:29 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.68.223.67 with SMTP id qs3ls13655188pbc.8.gmail; Sun, 21 Oct 2012 08:18:28 -0700 (PDT) Original-Received: by 10.66.72.42 with SMTP id a10mr1782149pav.34.1350832708939; Sun, 21 Oct 2012 08:18:28 -0700 (PDT) Original-Received: by 10.66.72.42 with SMTP id a10mr1782148pav.34.1350832708927; Sun, 21 Oct 2012 08:18:28 -0700 (PDT) Original-Received: from cm04fe.IST.Berkeley.EDU (cm04fe.IST.Berkeley.EDU. [169.229.218.145]) by gmr-mx.google.com with ESMTPS id pw7si1548524pbb.0.2012.10.21.08.18.28 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 21 Oct 2012 08:18:28 -0700 (PDT) Received-SPF: neutral (google.com: 169.229.218.145 is neither permitted nor denied by best guess record for domain of jgm-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org) client-ip=169.229.218.145; Original-Received: from li55-134.members.linode.com ([74.82.3.134] helo=johnmacfarlane.net) by cm04fe.ist.berkeley.edu with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (auth plain:jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org) (envelope-from ) id 1TPxII-0002TH-G1 for pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; Sun, 21 Oct 2012 08:18:28 -0700 Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id 8FCEABC680; Sun, 21 Oct 2012 11:13:58 -0400 (EDT) In-Reply-To: X-PGP-Key: http://johnmacfarlane.net/jgm.asc User-Agent: Mutt/1.5.21 (2010-09-15) X-Original-Sender: fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 169.229.218.145 is neither permitted nor denied by best guess record for domain of jgm-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org) smtp.mail=jgm-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@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: Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-Subscribe: , List-Unsubscribe: , Content-Disposition: inline Xref: news.gmane.org gmane.text.pandoc:4938 Archived-At: You won't be able to change the color of the bullets with this method. Given what you want to do, your best bet might be to add a new writer (a variant of the markdown writer) or perhaps add a "writerAnsiColors" option to WriterOptions and use it in the markdown writer. +++ Qubyte [Oct 21 12 02:15 ]: > Hi all, > > Someone recently asked me if it was possible to pretty print markdown > in a terminal, for example to preview git commit messages and such. I'm > playing around with the idea as basically stripping some formatting (I > don't need # or === but I want to keep bullets or numbers for lists) > and injecting in colours, bold, underlines etc. So far I have: > > import Text.Pandoc > colour :: Block -> Block > colour (Header n xs) = Para $ map modHeader xs > --colour (BulletList xs) = BulletList $ map modBullet xs > colour x = x > modHeader :: Inline -> Inline > modHeader (Str xs) = Str $ "\x1b[1m\x1b[32m" ++ xs ++ "\x1b[0m" > modHeader x = x > --modBullets :: Block -> Block > --modBullets (Plain xs) = Plain $ map modBullet xs > --modBullet :: Inline -> Inline > --modBullet (Str xs) = Str $ "\x1b[1m\x1b[32m" ++ xs ++ "\x1b[0m" > main :: IO () > main = toJsonFilter $ colour > > Which just makes all headers green (I'll add in cases for different > depths later). I'm having trouble with bullet lists though. I'd like to > mutate them either into a single paragraph with injected newlines and > dashes for bullets (and characters for colour encoding) or modify the > content of each point with inline colour encoding. To execute what I > have so far, I compile as toTerminal and run files through pandoc like: > > pandoc -t json something.markdown | ./toTerminal | pandoc -f json -t > plain > > And hints or tips would be very much appreciated! If I can get the > bullet lists working, I'm pretty sure I can figure the rest out. :) > > Thanks, > > Mark > > -- > You received this message because you are subscribed to the Google > Groups "pandoc-discuss" group. > To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > [1]https://groups.google.com/d/msg/pandoc-discuss/-/7NiJS5t6WnAJ. > For more options, visit [2]https://groups.google.com/groups/opt_out. > > References > > 1. https://groups.google.com/d/msg/pandoc-discuss/-/7NiJS5t6WnAJ > 2. https://groups.google.com/groups/opt_out