public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to add raw Markdown in filter?
@ 2017-10-09  1:38 Ivan Lazar Miljenovic
       [not found] ` <CA+u6gbxdqnG3Ok00OmZiC1V4kW6GyAZKnuS2robnJNq+z_Z2AQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Ivan Lazar Miljenovic @ 2017-10-09  1:38 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Is there any way using a filter to be able to inject markdown into a
document using a filter and have it be parsed/processed when
converting?  Ideally, I'd like to be able to generate PDF from the
result (`pandoc --read=markdown --write=latex --output=foo.pdf
--filter=./myFilter input.md`).

Using `RawBlock "markdown"` doesn't work as the rest of the document
has already been parsed, so the contents of those blocks are then
ignored.

As such, as far as I'm aware my options are:

* Try and write my own mini-parser that handles a subset of Markdown
and thus the filter can inject the correct Haskell representation of
the intended Markdown

* Use a 2-stage process for Pandoc to first apply the filter and write
out to Markdown, then pipe the results into Pandoc to convert to PDF
(not ideal as this is for a library that should be able to just
generate whatever results you want).

Is there anything else I can try and do?

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
http://IvanMiljenovic.wordpress.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to add raw Markdown in filter?
       [not found] ` <CA+u6gbxdqnG3Ok00OmZiC1V4kW6GyAZKnuS2robnJNq+z_Z2AQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-10-09  3:50   ` John MacFarlane
       [not found]     ` <20171009035026.GF20728-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
  2017-10-10 10:52   ` Saivan Hamama
  1 sibling, 1 reply; 4+ messages in thread
From: John MacFarlane @ 2017-10-09  3:50 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

If you write the filter in Haskell, you can simply use
the readMarkdown file from Text.Pandoc to parse the
Markdown.

Note that the lua filters functionality in the dev version
also provides access to the parsers, so you can do this
in lua also.

In other languages you'd have to shell out to pandoc.

+++ Ivan Lazar Miljenovic [Oct 09 17 12:38 ]:
>Is there any way using a filter to be able to inject markdown into a
>document using a filter and have it be parsed/processed when
>converting?  Ideally, I'd like to be able to generate PDF from the
>result (`pandoc --read=markdown --write=latex --output=foo.pdf
>--filter=./myFilter input.md`).
>
>Using `RawBlock "markdown"` doesn't work as the rest of the document
>has already been parsed, so the contents of those blocks are then
>ignored.
>
>As such, as far as I'm aware my options are:
>
>* Try and write my own mini-parser that handles a subset of Markdown
>and thus the filter can inject the correct Haskell representation of
>the intended Markdown
>
>* Use a 2-stage process for Pandoc to first apply the filter and write
>out to Markdown, then pipe the results into Pandoc to convert to PDF
>(not ideal as this is for a library that should be able to just
>generate whatever results you want).
>
>Is there anything else I can try and do?
>
>-- 
>Ivan Lazar Miljenovic
>Ivan.Miljenovic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
>http://IvanMiljenovic.wordpress.com
>
>-- 
>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/CA%2Bu6gbxdqnG3Ok00OmZiC1V4kW6GyAZKnuS2robnJNq%2Bz_Z2AQ%40mail.gmail.com.
>For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to add raw Markdown in filter?
       [not found]     ` <20171009035026.GF20728-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
@ 2017-10-09  3:54       ` Ivan Lazar Miljenovic
  0 siblings, 0 replies; 4+ messages in thread
From: Ivan Lazar Miljenovic @ 2017-10-09  3:54 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On 9 October 2017 at 14:50, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
> If you write the filter in Haskell, you can simply use
> the readMarkdown file from Text.Pandoc to parse the
> Markdown.

Might have to do that, but was hoping to keep it using pandoc-types
only for licensing reasons (maybe just tell end-users to do it?
*shrug*).

> Note that the lua filters functionality in the dev version
> also provides access to the parsers, so you can do this
> in lua also.
>
> In other languages you'd have to shell out to pandoc.
>
> +++ Ivan Lazar Miljenovic [Oct 09 17 12:38 ]:
>>
>> Is there any way using a filter to be able to inject markdown into a
>> document using a filter and have it be parsed/processed when
>> converting?  Ideally, I'd like to be able to generate PDF from the
>> result (`pandoc --read=markdown --write=latex --output=foo.pdf
>> --filter=./myFilter input.md`).
>>
>> Using `RawBlock "markdown"` doesn't work as the rest of the document
>> has already been parsed, so the contents of those blocks are then
>> ignored.
>>
>> As such, as far as I'm aware my options are:
>>
>> * Try and write my own mini-parser that handles a subset of Markdown
>> and thus the filter can inject the correct Haskell representation of
>> the intended Markdown
>>
>> * Use a 2-stage process for Pandoc to first apply the filter and write
>> out to Markdown, then pipe the results into Pandoc to convert to PDF
>> (not ideal as this is for a library that should be able to just
>> generate whatever results you want).
>>
>> Is there anything else I can try and do?
>>
>> --
>> Ivan Lazar Miljenovic
>> Ivan.Miljenovic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
>> http://IvanMiljenovic.wordpress.com
>>
>> --
>> 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/CA%2Bu6gbxdqnG3Ok00OmZiC1V4kW6GyAZKnuS2robnJNq%2Bz_Z2AQ%40mail.gmail.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/20171009035026.GF20728%40Johns-MacBook-Pro.local.
> For more options, visit https://groups.google.com/d/optout.



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
http://IvanMiljenovic.wordpress.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to add raw Markdown in filter?
       [not found] ` <CA+u6gbxdqnG3Ok00OmZiC1V4kW6GyAZKnuS2robnJNq+z_Z2AQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2017-10-09  3:50   ` John MacFarlane
@ 2017-10-10 10:52   ` Saivan Hamama
  1 sibling, 0 replies; 4+ messages in thread
From: Saivan Hamama @ 2017-10-10 10:52 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 767 bytes --]

If you're willing to use python, panflute also exposes a run_pandoc option, 
that you can use in a filter to parse your markdown to an AST.
This should work if you're willing to go that route :)

-- 
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/47112b0a-d44a-40d5-8453-6628bbbc5720%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1208 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-10 10:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-09  1:38 How to add raw Markdown in filter? Ivan Lazar Miljenovic
     [not found] ` <CA+u6gbxdqnG3Ok00OmZiC1V4kW6GyAZKnuS2robnJNq+z_Z2AQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-09  3:50   ` John MacFarlane
     [not found]     ` <20171009035026.GF20728-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2017-10-09  3:54       ` Ivan Lazar Miljenovic
2017-10-10 10:52   ` Saivan Hamama

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).