public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Matthew Pickering <matthewtpickering-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Customize Conversion for Identifiers in Code Blocks
Date: Sat, 17 Jan 2015 23:06:01 +0000	[thread overview]
Message-ID: <CALuQ0m-6JL87AQ6fUy2yRs270iv+ioQv=RZu53Z-Nf5fQcVLkQ@mail.gmail.com> (raw)
In-Reply-To: <5699588b-678c-4de6-96c0-6505e7fbd950-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

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 <rjhala-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 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-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/5699588b-678c-4de6-96c0-6505e7fbd950%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


  parent reply	other threads:[~2015-01-17 23:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-17 21:05 Ranjit Jhala
     [not found] ` <5699588b-678c-4de6-96c0-6505e7fbd950-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-01-17 23:06   ` Matthew Pickering [this message]
     [not found]     ` <CALuQ0m-6JL87AQ6fUy2yRs270iv+ioQv=RZu53Z-Nf5fQcVLkQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-18  0:44       ` Ranjit Jhala
     [not found]         ` <0d47cfc0-2a3d-4248-bd35-317dcd6a738b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-01-18  0:45           ` Matthew Pickering
     [not found]             ` <CALuQ0m8q+VwiaeZ2pJJKUHpx9w8bJgTw6K2N1LqKqHTaA-5tEg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-18  1:15               ` Ranjit Jhala
     [not found]                 ` <ca72b4ed-aac7-4a6a-9e0f-580bcc450f5f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-01-18 14:22                   ` Matthew Pickering
     [not found]                     ` <CALuQ0m8J-s2f3MTNTP9+uhG-QtHaFb6C13YZA91aHJWLauAJag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-18 14:22                       ` Matthew Pickering
     [not found]                         ` <CALuQ0m8aO6+cTS0M1+_o1iEWNk3H-q4c7o72iuiKEfLuPzoWrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-18 17:31                           ` Ranjit Jhala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALuQ0m-6JL87AQ6fUy2yRs270iv+ioQv=RZu53Z-Nf5fQcVLkQ@mail.gmail.com' \
    --to=matthewtpickering-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).