public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Conditional markdown parsing?
Date: Mon, 11 Nov 2019 14:44:23 -0800	[thread overview]
Message-ID: <yh480kr22ef2yg.fsf@johnmacfarlane.net> (raw)
In-Reply-To: <CAJReL340iudWT0DV+CuCyJwr_Go0H0YjcsAeu+tqX6om5Q1XZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>


It looks like it should work.  Try using the filter but going
`-t native` to see what comes out the other end.

Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi John,
>
> This function worked very well for me but I've modified my LaTeX function
> to take an extra argument and now I'm struggling to make it work:
>
>           return {pandoc.RawBlock('latex', '\\begin{' .. class ..
> '}[Some Title]'),
>                   el,
>                   pandoc.RawBlock('latex', '\\end{' .. class .. '}')}
>
>
> This compiles but it doesn't work as I expect it to. The intended title is
> rendered as part of the body instead (together with `el`). If I instead
> have the LaTeX directly, it works:
>
>                   \begin{notebox}[Custom title]
>
>                       some content
>
>                   \end{notebox}
>
>
> Any hints?
>
> Thanks!
>
> On Tue, 1 Oct 2019 at 21:57, Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> This is awesome! Thank you so much, I'll give it a try very soon.
>>
>> On Tue, 1 Oct 2019 at 18:54, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>>
>>>
>>> You can write a fairly simple filter that will do this for you, yes.
>>>
>>> % cat divToEnv.lua
>>> function Div(el)
>>>     if FORMAT == 'latex' then
>>>         local envname = el.classes[1]
>>>         return {pandoc.RawBlock('latex', '\\begin{' .. envname .. '}'),
>>>                 el,
>>>                 pandoc.RawBlock('latex', '\\end{' .. envname .. '}')}
>>>     end
>>> end
>>>
>>> % pandoc --lua-filter divToEnv.lua -t latex
>>> <div class="foo">
>>> hi there
>>> </div>
>>> ^D
>>> \begin{foo}
>>>
>>> hi there
>>>
>>> \end{foo}
>>>
>>> % pandoc --lua-filter divToEnv.lua -t html5
>>> <div class="foo">
>>> hi there
>>> </div>
>>> ^D
>>> <div class="foo">
>>> <p>hi there</p>
>>> </div>
>>>
>>> Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>>
>>> > Or even better, can `pandoc` identify <div> blocks when parsing
>>> markdown to
>>> > pdf and if so, apply some LaTeX style instead?
>>> >
>>> > That'd be great to avoid repeating text. I should be able to just write:
>>> >
>>> >  <div class="foo">
>>> >   some text
>>> >  </div>
>>> >
>>> > And then have the conditional logic in my LaTeX template file.
>>> >
>>> > On Tuesday, 1 October 2019 18:09:19 UTC-5, Gabriel Volpe wrote:
>>> >>
>>> >> Hi,
>>> >>
>>> >> I'm in search of something similar to this:
>>> >>
>>> https://groups.google.com/forum/#!searchin/pandoc-discuss/conditional%7Csort:date/pandoc-discuss/R00dbPcjYRY/An6ZEYNwAgAJ
>>> >>
>>> >> But instead, I want a specific output for LaTeX and another for EPUB
>>> >> (which goes through HTML). Basically, something like
>>> >>
>>> >> $if(outputformat=latex)$
>>> >>   \begin{foo}
>>> >>   some text
>>> >>   \end{foo}
>>> >> $endif$
>>> >>
>>> >> $if(outputformat=epub)$
>>> >>   <div class="foo">
>>> >>   some text
>>> >>   </div>
>>> >> $endif$
>>> >>
>>> >> I had a look into
>>> https://pandoc.org/MANUAL.html#extension-raw_attribute but
>>> >> I'm not being able to understand how I can get this working.
>>> >>
>>> >> Can anyone shed some light on me?
>>> >>
>>> >> Thanks!
>>> >>
>>> >
>>> > --
>>> > 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pandoc-discuss/dbfa5bfc-fba7-4309-abe0-7e432cd13b9b%40googlegroups.com
>>> .
>>>
>>


  parent reply	other threads:[~2019-11-11 22:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-01 23:09 Gabriel Volpe
     [not found] ` <78a2892d-a12d-4118-b36d-e38994d0a71a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-10-01 23:38   ` Gabriel Volpe
2019-10-01 23:38   ` Gabriel Volpe
     [not found]     ` <dbfa5bfc-fba7-4309-abe0-7e432cd13b9b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-10-01 23:54       ` John MacFarlane
     [not found]         ` <yh480kpnjg10pz.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-10-02  0:57           ` Gabriel Volpe
     [not found]             ` <CAJReL36Vyd-DjWan_q-fc5hOrPHr=K5x34vn8vi3KHWF7qEt7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-11-11 22:25               ` Gabriel Volpe
     [not found]                 ` <CAJReL340iudWT0DV+CuCyJwr_Go0H0YjcsAeu+tqX6om5Q1XZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-11-11 22:44                   ` John MacFarlane [this message]
     [not found]                     ` <yh480kr22ef2yg.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-11-11 23:00                       ` Gabriel Volpe
     [not found]                         ` <CAJReL35qw5+mgbQunSzi7M_f8sCG=9JuUX39MKvoWA1PrdXeAg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-11-11 23:46                           ` Gabriel Volpe
     [not found]                             ` <CAJReL34JZQGVSaWW=Ye4zh4BxMzwO+NVT-6gOadRjuDicuLypg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-11-11 23:47                               ` Gabriel Volpe
2019-11-12  0:50                           ` John MacFarlane
     [not found]                             ` <yh480ky2wlex3l.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-11-12  1:04                               ` Gabriel Volpe
     [not found]                                 ` <CAJReL34R_VO1g+KeyH5Jex70NCfVqCObv8ib3rfj492htJxNqA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-11-12  1:06                                   ` Gabriel Volpe
     [not found]                                     ` <CAJReL37iMLePBAP0Lwa-dDVfnBZ+8jJ00b79XH8b0Nvyv0eXPA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-11-12  1:18                                       ` Gabriel Volpe

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=yh480kr22ef2yg.fsf@johnmacfarlane.net \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@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).