From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/11784 Path: news.gmane.org!not-for-mail From: Ranjit Jhala Newsgroups: gmane.text.pandoc Subject: Re: Customize Conversion for Identifiers in Code Blocks Date: Sun, 18 Jan 2015 09:31:57 -0800 Message-ID: <34F3F3A0-8225-410C-8CDF-596724E52574@eng.ucsd.edu> References: <5699588b-678c-4de6-96c0-6505e7fbd950@googlegroups.com> <0d47cfc0-2a3d-4248-bd35-317dcd6a738b@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1421602322 26809 80.91.229.3 (18 Jan 2015 17:32:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Jan 2015 17:32:02 +0000 (UTC) Cc: "pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org" To: "pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org" Original-X-From: pandoc-discuss+bncBCP7R3MY74LRBEG456SQKGQEBVV5TJY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Jan 18 18:32:02 2015 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-yk0-f188.google.com ([209.85.160.188]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YCthh-0001t5-TE for gtp-pandoc-discuss@m.gmane.org; Sun, 18 Jan 2015 18:32:02 +0100 Original-Received: by mail-yk0-f188.google.com with SMTP id q200sf324956ykb.5 for ; Sun, 18 Jan 2015 09:32:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=references:mime-version:in-reply-to:content-type:message-id:cc:from :subject:date:to:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:sender:list-subscribe:list-unsubscribe; bh=ADD/EY3WmFCLgaZPHVVx71w6ESd4ME/kZ87V/bQWjGg=; b=KZxXXTBCy5Q35sw6+3x4lLZvnLun4kPWxnfqFmd1caMq+zzb4s/owqKjgtUf8caYtq WYMw4G95lLoEITfKxSvKTcn56l4QfqGPOcE7wIWV5r645/oaC5fQNwJRI459AmBf2Oii hCNInVH9KW/MTIQSUNn1LGI7pNr4ic7Tu88T+NJaT90vkghB4OA7N/Sff4F0tESFeDoj inOAI8jPQ1iY8uXdPxWwY2xiuTN14PoV4tzjB43KVAeHzY9xoVxkHWX4IM2wZ/t0cnm0 ZYTqCRlVNfMXWUUhVytWTA8eBiL+1mNq3y1u/Q5mj5PCYLDvVWKsSNwKWA8uOmgBQkyn aa0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:references:mime-version:in-reply-to:content-type :message-id:cc:from:subject:date:to:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe; bh=ADD/EY3WmFCLgaZPHVVx71w6ESd4ME/kZ87V/bQWjGg=; b=TImBpOHPkMyBC81yCYolayJ8vs3tZkzVg5nYqxvsh2tLNuJ1VgMwGRmxyvwNSVJSWU iGZbsqSsGXeHlZQsfD6IxZ6+u8tGXXNJ7Wf+d2VpRk3R0mvPkiXf0xlAG79ekdEc3hTJ Ucsr3+N1MHTEOyvPiG4uQi4HySkaZYeV5InBTzNYhK3Re3GmbgHriPEyUMH0rx+KCzxI lbadknQiZfUkdiyc/BS7p/rd/WoqkG2cA0CxzFMO/e2ivJ7y2pRmiPZbd+tjNDoU5kRf sJfqw5uedYVvi0PBhCiaZPOSx1Nuq1ptHeCPVlgt3/AlZ/RxqP6qQ/RGGIEEW+ukSINS dbCg== X-Received: by 10.50.97.99 with SMTP id dz3mr165574igb.1.1421602321073; Sun, 18 Jan 2015 09:32:01 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.50.65.102 with SMTP id w6ls22497igs.39.gmail; Sun, 18 Jan 2015 09:32:00 -0800 (PST) X-Received: by 10.68.65.70 with SMTP id v6mr19742024pbs.1.1421602320434; Sun, 18 Jan 2015 09:32:00 -0800 (PST) Original-Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com. [209.85.192.181]) by gmr-mx.google.com with ESMTPS id jy5si1098360pbc.2.2015.01.18.09.32.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Jan 2015 09:32:00 -0800 (PST) Received-SPF: none (google.com: rjhala-fWt/sZ2FBdz2fBVCVOL8/A@public.gmane.org does not designate permitted sender hosts) client-ip=209.85.192.181; Original-Received: by mail-pd0-f181.google.com with SMTP id z10so20460351pdj.12 for ; Sun, 18 Jan 2015 09:32:00 -0800 (PST) X-Gm-Message-State: ALoCoQlO3TEWipkUIKb+F/MkWvoWwKaVR+D82inxFFIO0OzRS4DHo/LRV+M2azCXsn5g+wyOslbu X-Received: by 10.68.213.132 with SMTP id ns4mr38337987pbc.148.1421602320189; Sun, 18 Jan 2015 09:32:00 -0800 (PST) Original-Received: from [10.180.42.209] (128.sub-70-209-199.myvzw.com. [70.209.199.128]) by mx.google.com with ESMTPSA id v4sm9478671pdj.22.2015.01.18.09.31.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Jan 2015 09:31:59 -0800 (PST) In-Reply-To: X-Mailer: iPhone Mail (11B554a) X-Original-Sender: rjhala-fWt/sZ2FBdz2fBVCVOL8/A@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=none (google.com: rjhala-fWt/sZ2FBdz2fBVCVOL8/A@public.gmane.org does not designate permitted sender hosts) smtp.mail=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:11784 Archived-At: Thanks Matthew! I'll look into this. I'm guessing from this http://blog.jeci.fr/post/87994249356/adding-new-highlighting-language-into-pandoc That I need to rebuild highlighting-Kate and pandoc? (Or can I specify the XML style file a command line parameter?) > On Jan 18, 2015, at 6:22 AM, Matthew Pickering wrote: > > https://hackage.haskell.org/package/highlighting-kate > > On Sun, Jan 18, 2015 at 2:22 PM, Matthew Pickering > wrote: >> Ah I think you will need to do something more complicated then. >> >> Pandoc uses highlighting-kate[1] to do syntax highlighting. >> >> Looking at the API, it seems like it should be possible to perform the >> transformation you describe. I can try and figure it out later if you >> need some help. >> >> >>> On Sun, Jan 18, 2015 at 1:15 AM, Ranjit Jhala wrote: >>> Thanks! I tried that and the filter indeed compiles but converting a single >>> `CodeBlock` into a list of `CodeBlock` and `latex` blocks >>> has the unfortunate effect of introducing line breaks everywhere (I think >>> this is because a line break is introduced wherever a code block ends, >>> right?) >>> >>> >>>> On Saturday, January 17, 2015 at 4:45:54 PM UTC-8, Matthew Pickering wrote: >>>> >>>> f :: Maybe Format -> Block -> [Block] should work fine. >>>> >>>> >>>> https://hackage.haskell.org/package/pandoc-types-1.12.2.1/docs/Text-Pandoc-JSON.html >>>> >>>> On Sun, Jan 18, 2015 at 12:44 AM, Ranjit Jhala >>>> wrote: >>>>> 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...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> To post to this group, send email to pandoc-...-/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. >>> >>> -- >>> 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/ca72b4ed-aac7-4a6a-9e0f-580bcc450f5f%40googlegroups.com. >>> >>> For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to a topic in the Google Groups "pandoc-discuss" group. > To unsubscribe from this topic, visit https://groups.google.com/d/topic/pandoc-discuss/Qk9tTK5LPOo/unsubscribe. > To unsubscribe from this group and all its topics, 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/CALuQ0m8aO6%2BcTS0M1%2B_o1iEWNk3H-q4c7o72iuiKEfLuPzoWrA%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout.