From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/4946 Path: news.gmane.org!not-for-mail From: Qubyte Newsgroups: gmane.text.pandoc Subject: Re: Making a simple script to send coloured output to a terminal. Date: Mon, 22 Oct 2012 07:39:49 -0700 (PDT) Message-ID: <71200532-9ae5-4c47-b3ac-9abcab5387ac@googlegroups.com> References: <20121021151831.GB30752@Johns-MacBook-Pro.local> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_12_55097.1350916789911" X-Trace: ger.gmane.org 1350916791 23356 80.91.229.3 (22 Oct 2012 14:39:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Oct 2012 14:39:51 +0000 (UTC) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDUL7FOJRUARBNVVSWCAKGQEUTTOGHQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Oct 22 16:39:58 2012 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-lb0-f186.google.com ([209.85.217.186]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TQJAc-0005o7-GF for gtp-pandoc-discuss@m.gmane.org; Mon, 22 Oct 2012 16:39:58 +0200 Original-Received: by mail-lb0-f186.google.com with SMTP id gn12sf1165948lbb.3 for ; Mon, 22 Oct 2012 07:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=M7CB3PL2Tx4roi6PwNgtzs3UljV5BUTKkOLqlIW4zso=; b=LDBiy6T9kK+HvTzGpRa3MdxhBhrtHQRua/bbqKT42Kl+uUeITejxfXFahpWR3qix6l EspcrpQZNFVUBPfs2e4xEJM/D/uDJdZmuiezs8o3+0H9Ei9WIhQe9d9EE7iynx46FFfo ocWSyLtSVPdpz+qAA2ccGts9qsabopfc9h5675kdBVmlKKw1Gvpdj6GBghmwQPf9kHnv rlDp82SBDmUaTlJ00mchl169gveXXMhxii3hqF0mTbR/1TSGiFoDzh0yXjyiFfhiUBlr Glp0lHiJwN1UFAEhOCPNgzx4oqSE61cdvSpE8KUgmc2Z+yH3i1IdT5PfaiiTn8M/JFtj L2lg== Original-Received: by 10.180.101.6 with SMTP id fc6mr1532958wib.4.1350916790937; Mon, 22 Oct 2012 07:39:50 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.14.198.201 with SMTP id v49ls1206850een.0.gmail; Mon, 22 Oct 2012 07:39:50 -0700 (PDT) Original-Received: by 10.68.223.98 with SMTP id qt2mr2479782pbc.20.1350916790236; Mon, 22 Oct 2012 07:39:50 -0700 (PDT) In-Reply-To: <20121021151831.GB30752-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org> X-Original-Sender: mark.s.everitt-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: Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-Subscribe: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:4946 Archived-At: ------=_Part_12_55097.1350916789911 Content-Type: text/plain; charset=ISO-8859-1 Thanks, I'll give that a try and post something here when I have some progress. On Monday, 22 October 2012 00:18:29 UTC+9, fiddlosopher wrote: > > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. > > > To unsubscribe from this group, send email to > > pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@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 > -- 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 https://groups.google.com/d/msg/pandoc-discuss/-/NrNg9r8LZu4J. For more options, visit https://groups.google.com/groups/opt_out. ------=_Part_12_55097.1350916789911 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks, I'll give that a try and post something here when I have some progr= ess.

On Monday, 22 October 2012 00:18:29 UTC+9, fiddlosopher wrote:=
You won't be able to change th= e 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,
>=20
>    Someone recently asked me if it was possible to prett= y print markdown
>    in a terminal, for example to preview git commit mess= ages and such. I'm
>    playing around with the idea as basically stripping s= ome formatting (I
>    don't need # or =3D=3D=3D but I want to keep bullets = or numbers for lists)
>    and injecting in colours, bold, underlines etc. So fa= r I have:
>=20
>    import Text.Pandoc
>    colour :: Block -> Block
>    colour (Header n xs) =3D Para $ map modHeader xs
>    --colour (BulletList xs) =3D BulletList $ map modBull= et xs
>    colour x =3D x
>    modHeader :: Inline -> Inline
>    modHeader (Str xs) =3D Str $ "\x1b[1m\x1b[32m" ++ xs = ++ "\x1b[0m"
>    modHeader x =3D x
>    --modBullets :: Block -> Block
>    --modBullets (Plain xs) =3D Plain $ map modBullet xs
>    --modBullet :: Inline -> Inline
>    --modBullet (Str xs) =3D Str $ "\x1b[1m\x1b[32m" ++ x= s ++ "\x1b[0m"
>    main :: IO ()
>    main =3D toJsonFilter $ colour
>=20
>    Which just makes all headers green (I'll add in cases= for different
>    depths later). I'm having trouble with bullet lists t= hough. I'd like to
>    mutate them either into a single paragraph with injec= ted newlines and
>    dashes for bullets (and characters for colour encodin= g) 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 th= rough pandoc like:
>=20
>    pandoc -t json something.markdown | ./toTerminal | pa= ndoc -f json -t
>    plain
>=20
>    And hints or tips would be very much appreciated! If = I can get the
>    bullet lists working, I'm pretty sure I can figure th= e rest out. :)
>=20
>    Thanks,
>=20
>    Mark
>=20
>    --
>    You received this message because you are subscribed = to the Google
>    Groups "pandoc-discuss" group.
>    To post to this group, send email to pandoc-...= @googlegroups.com.
>    To unsubscribe from this group, send email to
>    pandoc-discus...@googlegroups.com.
>    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.
>=20
> References
>=20
>    1. https://groups.google.com/d/= msg/pandoc-discuss/-/7NiJS5t6WnAJ
>    2. https://groups.google.com/groups/opt_out

--
You received this message because you are subscribed to the Google Groups &= quot;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@go= oglegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/pan= doc-discuss/-/NrNg9r8LZu4J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
------=_Part_12_55097.1350916789911--