From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/11775 Path: news.gmane.org!not-for-mail From: Ranjit Jhala Newsgroups: gmane.text.pandoc Subject: Re: Customize Conversion for Identifiers in Code Blocks Date: Sat, 17 Jan 2015 16:44:14 -0800 (PST) Message-ID: <0d47cfc0-2a3d-4248-bd35-317dcd6a738b@googlegroups.com> References: <5699588b-678c-4de6-96c0-6505e7fbd950@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_423_497692908.1421541854019" X-Trace: ger.gmane.org 1421541856 21744 80.91.229.3 (18 Jan 2015 00:44:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Jan 2015 00:44:16 +0000 (UTC) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCP7R3MY74LRBXUD5SSQKGQEGYWAVXQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Jan 18 01:44:16 2015 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-qa0-f60.google.com ([209.85.216.60]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YCdyR-0002np-NN for gtp-pandoc-discuss@m.gmane.org; Sun, 18 Jan 2015 01:44:15 +0100 Original-Received: by mail-qa0-f60.google.com with SMTP id w8sf3841190qac.5 for ; Sat, 17 Jan 2015 16:44:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :content-type:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe; bh=wy6aKdpWpSslhFoUT5Pd2a6qRwjbWNhw5rP2mSI47wE=; b=rt53bdmikXvpxYG3s3YJTsSKapSSawpj6J2rmCjgS79KGw0BWyRJPdbEkbCwY/mQUX rilJk9DUWY1eosaSLuVrLphNbLywFjiSSCKhoHkudsVrYI/qcPjCtI0RjpEqJC5aG1ju ZXIux+iZhk5xb4+jidbKV3Yx7MOk9yaikSq6CmJKyKSOl9O9wbVJgZZUODZBq25gKKYa XkAvSMt3NABuLlQRoYCNhdKhs8vAMn0hB6tVTNT7rANsy68BppM9vvL1wrofCGz7DL8h QnRx1RVHRGSn5wpER3tjILYpyp4IyzRsU5zaaOqn1oBTPQHZKqKkJsCuszqvuKfxWMJt PnHg== X-Received: by 10.182.165.168 with SMTP id yz8mr12441obb.15.1421541855034; Sat, 17 Jan 2015 16:44:15 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.182.56.166 with SMTP id b6ls834981obq.74.gmail; Sat, 17 Jan 2015 16:44:14 -0800 (PST) X-Received: by 10.182.214.106 with SMTP id nz10mr166196obc.4.1421541854540; Sat, 17 Jan 2015 16:44:14 -0800 (PST) In-Reply-To: X-Original-Sender: rjhala-fWt/sZ2FBdz2fBVCVOL8/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.org gmane.text.pandoc:11775 Archived-At: ------=_Part_423_497692908.1421541854019 Content-Type: multipart/alternative; boundary="----=_Part_424_275899691.1421541854020" ------=_Part_424_275899691.1421541854020 Content-Type: text/plain; charset=UTF-8 Hi Matthew, The catch is that there's a bunch of other stuff in the `Block`. That is, the special token is some substring of `s` f :: Block -> Block f (CodeBlock _ s) = RawBlock (Format "latex") ("\\MySpecialToken{" ++ s ++ "}") f b = b and I don't want to lose that. So I can write a function f :: Block -> [Block] where each CodeBlock is expanded into a list of : `RawBlock (Format "latex")` of the kind above, and the remaining, unchanged CodeBlock But that causes problems with toJSONFilter as I can't pass in a transformation of the form [Block] -> [Block] Because there is no instance of Walkable for [Block] ... :( On Saturday, January 17, 2015 at 3:06:04 PM UTC-8, Matthew Pickering wrote: > > You can write a filter ... f :: Block -> Block and have something like > the following. > > f :: Block -> Block > f (CodeBlock _ s) = RawBlock (Format "latex") ("\\MySpecialToken{" ++ s > ++ "}") > f b = b > > Do you also plan to output to other formats? If so then "toJSONFilter" > can take a function of type "f :: Maybe Format -> Block -> Block" > where the first argument is the output format. > > Does that make sense? > > On Sat, Jan 17, 2015 at 9:05 PM, Ranjit Jhala > wrote: > > Hi, > > > > I'd like to write a filter that runs on `CodeBlock` such that each > > identifier that begins > > with (say) "$$$mytoken" gets rendered in latex not as a > > > > \NormalTok{$$$mytoken} > > > > but as > > > > \MySpecialToken{$$$mytoken} > > > > Can anyone give me a hint as to how to proceed? The stumbling block is > that > > it seems like > > the filter should "preserve" the type, so I can write a > > > > myFilter :: CodeBlock -> CodeBlock > > > > But the `CodeBlock` type only allows strings -- presumably just > replacing > > (substrings) of the form > > > > $$$mytoken > > > > with > > > > \MySpecialToken{$$$mytoken} > > > > will only cause the latter to then get "escaped" out during the final > latex > > conversion? > > > > Any pointers would be most welcome! > > > > Thanks! > > > > - Ranjit. > > > > -- > > 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . > > To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/pandoc-discuss/5699588b-678c-4de6-96c0-6505e7fbd950%40googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > -- 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0d47cfc0-2a3d-4248-bd35-317dcd6a738b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_424_275899691.1421541854020 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Matthew,

The catch is that there's a= bunch of other stuff in the `Block`. 

That i= s, the special token is some substring of `s`

f ::= Block -> Block 
f (CodeBlock _ s) =3D RawBlock (Format "latex")=  ("\\MySpecialToken{" ++ s ++ "}") 
f b =3D b 
=

and I don't want to lose that. So I can write a functio= n 

    f :: Block -> [Block]

where each CodeBlock is expanded into a list of :

  `RawBlock (Format "latex")` of the kind above,=
  and the remaining, unchanged CodeBlock

But that causes problems with toJSONFilter as I can't pass in a tran= sformation of the form 

   [Block] = -> [Block]

Because there is no instance of Walk= able for [Block] ... :(

On Saturday, January 17, 2015 at 3:06= :04 PM UTC-8, Matthew Pickering wrote:
You can write a filter ... f :: Block -> Block and have somethin= g like
the following.

f :: Block -> Block
f (CodeBlock _ s) =3D RawBlock (Format "latex")  ("\\MySpecialToke= n{" ++ s ++ "}")
f b =3D b

Do you also plan to output to other formats? If so then "toJSONFilter"
can take a function of type "f :: Maybe Format -> Block -> Block"
where the first argument is the output format.

Does that make sense?

On Sat, Jan 17, 2015 at 9:05 PM, Ranjit Jhala <rjh...-fWt/sZ2FBdz2fBVCVOL8/A@public.gmane.org> wrote:
> Hi,
>
> I'd like to write a filter that runs on `CodeBlock` such that each
> identifier that begins
> with (say) "$$$mytoken" gets rendered in latex not as a
>
>     \NormalTok{$$$mytoken}
>
> but as
>
>     \MySpecialToken{$$$mytoken}
>
> Can anyone give me a hint as to how to proceed? The stumbling bloc= k is that
> it seems like
> the filter should "preserve" the type, so I can write a
>
>     myFilter :: CodeBlock -> CodeBlock
>
> But the `CodeBlock` type only allows strings -- presumably just re= placing
> (substrings) of the form
>
>     $$$mytoken
>
> with
>
>    \MySpecialToken{$$$mytoken}
>
> will only cause the latter to then get "escaped" out during the fi= nal latex
> conversion?
>
> Any pointers would be most welcome!
>
> Thanks!
>
> - Ranjit.
>
> --
> 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 pan= doc-discus...@googlegroups.com.
> To post to this group, send email to pandoc-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/5699588b-678c= -4de6-96c0-6505e7fbd950%40googlegroups.com.
> For more options, visit https://groups.google.com/d/= optout.

--
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/= msgid/pandoc-discuss/0d47cfc0-2a3d-4248-bd35-317dcd6a738b%40googlegroups.co= m.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_424_275899691.1421541854020-- ------=_Part_423_497692908.1421541854019--