From: Ranjit Jhala <rjhala-fWt/sZ2FBdz2fBVCVOL8/A@public.gmane.org>
To: "pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org"
<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Cc: "pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org"
<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Customize Conversion for Identifiers in Code Blocks
Date: Sun, 18 Jan 2015 09:31:57 -0800 [thread overview]
Message-ID: <34F3F3A0-8225-410C-8CDF-596724E52574@eng.ucsd.edu> (raw)
In-Reply-To: <CALuQ0m8aO6+cTS0M1+_o1iEWNk3H-q4c7o72iuiKEfLuPzoWrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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 <matthewtpickering-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> https://hackage.haskell.org/package/highlighting-kate
>
> On Sun, Jan 18, 2015 at 2:22 PM, Matthew Pickering
> <matthewtpickering-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 <rjhala-fWt/sZ2FBdz2fBVCVOL8/A@public.gmane.org> 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 <rjh...-fWt/sZ2FBdz2fBVCVOL8/A@public.gmane.org>
>>>> 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 <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 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.
prev parent reply other threads:[~2015-01-18 17:31 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
[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 [this message]
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=34F3F3A0-8225-410C-8CDF-596724E52574@eng.ucsd.edu \
--to=rjhala-fwt/sz2fbdz2fbvcvol8/a@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).