* Customize Conversion for Identifiers in Code Blocks
@ 2015-01-17 21:05 Ranjit Jhala
[not found] ` <5699588b-678c-4de6-96c0-6505e7fbd950-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 8+ messages in thread
From: Ranjit Jhala @ 2015-01-17 21:05 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1.1: Type: text/plain, Size: 1294 bytes --]
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.
[-- Attachment #1.2: Type: text/html, Size: 2172 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Customize Conversion for Identifiers in Code Blocks
[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>
0 siblings, 1 reply; 8+ messages in thread
From: Matthew Pickering @ 2015-01-17 23:06 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Customize Conversion for Identifiers in Code Blocks
[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>
0 siblings, 1 reply; 8+ messages in thread
From: Ranjit Jhala @ 2015-01-18 0:44 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1.1: Type: text/plain, Size: 3373 bytes --]
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
> <javascript:>> 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 <javascript:>.
> > To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> <javascript:>.
> > 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.
[-- Attachment #1.2: Type: text/html, Size: 5739 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Customize Conversion for Identifiers in Code Blocks
[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>
0 siblings, 1 reply; 8+ messages in thread
From: Matthew Pickering @ 2015-01-18 0:45 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
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 <rjhala-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-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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Customize Conversion for Identifiers in Code Blocks
[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>
0 siblings, 1 reply; 8+ messages in thread
From: Ranjit Jhala @ 2015-01-18 1:15 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1.1: Type: text/plain, Size: 4985 bytes --]
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
> <javascript:>> 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...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>.
> > To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> <javascript:>.
> > 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.
[-- Attachment #1.2: Type: text/html, Size: 8940 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Customize Conversion for Identifiers in Code Blocks
[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>
0 siblings, 1 reply; 8+ messages in thread
From: Matthew Pickering @ 2015-01-18 14:22 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Customize Conversion for Identifiers in Code Blocks
[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>
0 siblings, 1 reply; 8+ messages in thread
From: Matthew Pickering @ 2015-01-18 14:22 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Customize Conversion for Identifiers in Code Blocks
[not found] ` <CALuQ0m8aO6+cTS0M1+_o1iEWNk3H-q4c7o72iuiKEfLuPzoWrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-01-18 17:31 ` Ranjit Jhala
0 siblings, 0 replies; 8+ messages in thread
From: Ranjit Jhala @ 2015-01-18 17:31 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
Cc: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-01-18 17:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-17 21:05 Customize Conversion for Identifiers in Code Blocks 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 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).