public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Conditional markdown parsing?
@ 2019-10-01 23:09 Gabriel Volpe
       [not found] ` <78a2892d-a12d-4118-b36d-e38994d0a71a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Gabriel Volpe @ 2019-10-01 23:09 UTC (permalink / raw)
  To: pandoc-discuss


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

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/78a2892d-a12d-4118-b36d-e38994d0a71a%40googlegroups.com.

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

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

* Re: Conditional markdown parsing?
       [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
  1 sibling, 0 replies; 14+ messages in thread
From: Gabriel Volpe @ 2019-10-01 23:38 UTC (permalink / raw)
  To: pandoc-discuss


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

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/4d5081a5-015b-4bf5-9b77-390751319985%40googlegroups.com.

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

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

* Re: Conditional markdown parsing?
       [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>
  1 sibling, 1 reply; 14+ messages in thread
From: Gabriel Volpe @ 2019-10-01 23:38 UTC (permalink / raw)
  To: pandoc-discuss


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

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.

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

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

* Re: Conditional markdown parsing?
       [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>
  0 siblings, 1 reply; 14+ messages in thread
From: John MacFarlane @ 2019-10-01 23:54 UTC (permalink / raw)
  To: Gabriel Volpe, pandoc-discuss


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.


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

* Re: Conditional markdown parsing?
       [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>
  0 siblings, 1 reply; 14+ messages in thread
From: Gabriel Volpe @ 2019-10-02  0:57 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 2930 bytes --]

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

-- 
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/CAJReL36Vyd-DjWan_q-fc5hOrPHr%3DK5x34vn8vi3KHWF7qEt7Q%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 4857 bytes --]

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

* Re: Conditional markdown parsing?
       [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>
  0 siblings, 1 reply; 14+ messages in thread
From: Gabriel Volpe @ 2019-11-11 22:25 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 3786 bytes --]

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

-- 
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/CAJReL340iudWT0DV%2BCuCyJwr_Go0H0YjcsAeu%2BtqX6om5Q1XZw%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 6421 bytes --]

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

* Re: Conditional markdown parsing?
       [not found]                 ` <CAJReL340iudWT0DV+CuCyJwr_Go0H0YjcsAeu+tqX6om5Q1XZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-11-11 22:44                   ` John MacFarlane
       [not found]                     ` <yh480kr22ef2yg.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: John MacFarlane @ 2019-11-11 22:44 UTC (permalink / raw)
  To: Gabriel Volpe; +Cc: pandoc-discuss


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


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

* Re: Conditional markdown parsing?
       [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>
  0 siblings, 1 reply; 14+ messages in thread
From: Gabriel Volpe @ 2019-11-11 23:00 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 4922 bytes --]

Thanks. Using `-t native` to generate a `.tex` file I see the following
relevant element:

,Div ("",["box","box-note"],[])
 [Para [Str "A",Space,Str "note",Space,Str "on",Space,Str
"what\8217s",Space,Str "being",Space,Str "explained"]]
,RawBlock (Format "html") "<p/>"

If I try to generate a `pdf` as usual, I get the following error: "cannot
produce pdf output from native"

I don't really understand what's going on here, to be honest ...

On Mon, 11 Nov 2019 at 19:44, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:

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

-- 
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/CAJReL35qw5%2BmgbQunSzi7M_f8sCG%3D9JuUX39MKvoWA1PrdXeAg%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 8453 bytes --]

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

* Re: Conditional markdown parsing?
       [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-12  0:50                           ` John MacFarlane
  1 sibling, 1 reply; 14+ messages in thread
From: Gabriel Volpe @ 2019-11-11 23:46 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 5431 bytes --]

BTW if by any chance you're interested in FP Scala I'd be happy to give you
a copy of my work-in-progress book, where I also give credits to Pandoc
https://leanpub.com/pfp-scala/sales

Just let me know, you've been very helpful :)



On Mon, Nov 11, 2019, 20:00 Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Thanks. Using `-t native` to generate a `.tex` file I see the following
> relevant element:
>
> ,Div ("",["box","box-note"],[])
>  [Para [Str "A",Space,Str "note",Space,Str "on",Space,Str
> "what\8217s",Space,Str "being",Space,Str "explained"]]
> ,RawBlock (Format "html") "<p/>"
>
> If I try to generate a `pdf` as usual, I get the following error: "cannot
> produce pdf output from native"
>
> I don't really understand what's going on here, to be honest ...
>
> On Mon, 11 Nov 2019 at 19:44, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>
>>
>> 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
>> >>> .
>> >>>
>> >>
>>
>

-- 
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/CAJReL34JZQGVSaWW%3DYe4zh4BxMzwO%2BNVT-6gOadRjuDicuLypg%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 9371 bytes --]

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

* Re: Conditional markdown parsing?
       [not found]                             ` <CAJReL34JZQGVSaWW=Ye4zh4BxMzwO+NVT-6gOadRjuDicuLypg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-11-11 23:47                               ` Gabriel Volpe
  0 siblings, 0 replies; 14+ messages in thread
From: Gabriel Volpe @ 2019-11-11 23:47 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 5755 bytes --]

Wrong link, please remove the 'sales' part :D

On Mon, Nov 11, 2019, 20:46 Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> BTW if by any chance you're interested in FP Scala I'd be happy to give
> you a copy of my work-in-progress book, where I also give credits to Pandoc
> https://leanpub.com/pfp-scala/sales
>
> Just let me know, you've been very helpful :)
>
>
>
> On Mon, Nov 11, 2019, 20:00 Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> Thanks. Using `-t native` to generate a `.tex` file I see the following
>> relevant element:
>>
>> ,Div ("",["box","box-note"],[])
>>  [Para [Str "A",Space,Str "note",Space,Str "on",Space,Str
>> "what\8217s",Space,Str "being",Space,Str "explained"]]
>> ,RawBlock (Format "html") "<p/>"
>>
>> If I try to generate a `pdf` as usual, I get the following error: "cannot
>> produce pdf output from native"
>>
>> I don't really understand what's going on here, to be honest ...
>>
>> On Mon, 11 Nov 2019 at 19:44, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>>
>>>
>>> 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
>>> >>> .
>>> >>>
>>> >>
>>>
>>

-- 
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/CAJReL340w%2BdXeOJVXWVaviTw2ZV%3DoyyXTBeN5cLhtUSnwr1zUQ%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 9963 bytes --]

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

* Re: Conditional markdown parsing?
       [not found]                         ` <CAJReL35qw5+mgbQunSzi7M_f8sCG=9JuUX39MKvoWA1PrdXeAg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2019-11-11 23:46                           ` Gabriel Volpe
@ 2019-11-12  0:50                           ` John MacFarlane
       [not found]                             ` <yh480ky2wlex3l.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  1 sibling, 1 reply; 14+ messages in thread
From: John MacFarlane @ 2019-11-12  0:50 UTC (permalink / raw)
  To: Gabriel Volpe; +Cc: pandoc-discuss


The filter does a transformation of the AST.

So if you run

pandoc --lua-filter yourfilter.lua  -t native

you'll see what it transforms it TO, and that may help
you diagnose the problem.  (With this you won't get a
tex file, you'll get a representation of a Haskell
data structure.)

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

> Thanks. Using `-t native` to generate a `.tex` file I see the following
> relevant element:
>
> ,Div ("",["box","box-note"],[])
>  [Para [Str "A",Space,Str "note",Space,Str "on",Space,Str
> "what\8217s",Space,Str "being",Space,Str "explained"]]
> ,RawBlock (Format "html") "<p/>"
>
> If I try to generate a `pdf` as usual, I get the following error: "cannot
> produce pdf output from native"
>
> I don't really understand what's going on here, to be honest ...
>
> On Mon, 11 Nov 2019 at 19:44, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>
>>
>> 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
>> >>> .
>> >>>
>> >>
>>


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

* Re: Conditional markdown parsing?
       [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>
  0 siblings, 1 reply; 14+ messages in thread
From: Gabriel Volpe @ 2019-11-12  1:04 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 6082 bytes --]

Okay, I had to convert to LaTeX in order to find the issue:

Instead of being transformed as:


*\begin{note}[Custom Title]*

What happens is this:


*\begin{note}\[Custom Title\]*

Is this a bug?

On Mon, 11 Nov 2019 at 21:51, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:

>
> The filter does a transformation of the AST.
>
> So if you run
>
> pandoc --lua-filter yourfilter.lua  -t native
>
> you'll see what it transforms it TO, and that may help
> you diagnose the problem.  (With this you won't get a
> tex file, you'll get a representation of a Haskell
> data structure.)
>
> Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
> > Thanks. Using `-t native` to generate a `.tex` file I see the following
> > relevant element:
> >
> > ,Div ("",["box","box-note"],[])
> >  [Para [Str "A",Space,Str "note",Space,Str "on",Space,Str
> > "what\8217s",Space,Str "being",Space,Str "explained"]]
> > ,RawBlock (Format "html") "<p/>"
> >
> > If I try to generate a `pdf` as usual, I get the following error: "cannot
> > produce pdf output from native"
> >
> > I don't really understand what's going on here, to be honest ...
> >
> > On Mon, 11 Nov 2019 at 19:44, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
> >
> >>
> >> 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
> >> >>> .
> >> >>>
> >> >>
> >>
>

-- 
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/CAJReL34R_VO1g%2BKeyH5Jex70NCfVqCObv8ib3rfj492htJxNqA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 10795 bytes --]

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

* Re: Conditional markdown parsing?
       [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>
  0 siblings, 1 reply; 14+ messages in thread
From: Gabriel Volpe @ 2019-11-12  1:06 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 6505 bytes --]

Oh no, nevermind... I think it's another issue (my mistake). Will try to
nail it down, sorry for the noise.

On Mon, 11 Nov 2019 at 22:04, Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Okay, I had to convert to LaTeX in order to find the issue:
>
> Instead of being transformed as:
>
>
> *\begin{note}[Custom Title]*
>
> What happens is this:
>
>
> *\begin{note}\[Custom Title\]*
>
> Is this a bug?
>
> On Mon, 11 Nov 2019 at 21:51, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>
>>
>> The filter does a transformation of the AST.
>>
>> So if you run
>>
>> pandoc --lua-filter yourfilter.lua  -t native
>>
>> you'll see what it transforms it TO, and that may help
>> you diagnose the problem.  (With this you won't get a
>> tex file, you'll get a representation of a Haskell
>> data structure.)
>>
>> Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>
>> > Thanks. Using `-t native` to generate a `.tex` file I see the following
>> > relevant element:
>> >
>> > ,Div ("",["box","box-note"],[])
>> >  [Para [Str "A",Space,Str "note",Space,Str "on",Space,Str
>> > "what\8217s",Space,Str "being",Space,Str "explained"]]
>> > ,RawBlock (Format "html") "<p/>"
>> >
>> > If I try to generate a `pdf` as usual, I get the following error:
>> "cannot
>> > produce pdf output from native"
>> >
>> > I don't really understand what's going on here, to be honest ...
>> >
>> > On Mon, 11 Nov 2019 at 19:44, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>> >
>> >>
>> >> 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
>> >> >>> .
>> >> >>>
>> >> >>
>> >>
>>
>

-- 
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/CAJReL37iMLePBAP0Lwa-dDVfnBZ%2B8jJ00b79XH8b0Nvyv0eXPA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 11342 bytes --]

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

* Re: Conditional markdown parsing?
       [not found]                                     ` <CAJReL37iMLePBAP0Lwa-dDVfnBZ+8jJ00b79XH8b0Nvyv0eXPA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-11-12  1:18                                       ` Gabriel Volpe
  0 siblings, 0 replies; 14+ messages in thread
From: Gabriel Volpe @ 2019-11-12  1:18 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 6985 bytes --]

It effectively works, it was just my dumb mistake of not having the
expected parameter in my LaTeX.

Sorry for the noise and thanks again for your help!

On Mon, 11 Nov 2019 at 22:06, Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Oh no, nevermind... I think it's another issue (my mistake). Will try to
> nail it down, sorry for the noise.
>
> On Mon, 11 Nov 2019 at 22:04, Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
>
>> Okay, I had to convert to LaTeX in order to find the issue:
>>
>> Instead of being transformed as:
>>
>>
>> *\begin{note}[Custom Title]*
>>
>> What happens is this:
>>
>>
>> *\begin{note}\[Custom Title\]*
>>
>> Is this a bug?
>>
>> On Mon, 11 Nov 2019 at 21:51, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>>
>>>
>>> The filter does a transformation of the AST.
>>>
>>> So if you run
>>>
>>> pandoc --lua-filter yourfilter.lua  -t native
>>>
>>> you'll see what it transforms it TO, and that may help
>>> you diagnose the problem.  (With this you won't get a
>>> tex file, you'll get a representation of a Haskell
>>> data structure.)
>>>
>>> Gabriel Volpe <volpegabriel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>>
>>> > Thanks. Using `-t native` to generate a `.tex` file I see the following
>>> > relevant element:
>>> >
>>> > ,Div ("",["box","box-note"],[])
>>> >  [Para [Str "A",Space,Str "note",Space,Str "on",Space,Str
>>> > "what\8217s",Space,Str "being",Space,Str "explained"]]
>>> > ,RawBlock (Format "html") "<p/>"
>>> >
>>> > If I try to generate a `pdf` as usual, I get the following error:
>>> "cannot
>>> > produce pdf output from native"
>>> >
>>> > I don't really understand what's going on here, to be honest ...
>>> >
>>> > On Mon, 11 Nov 2019 at 19:44, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
>>> wrote:
>>> >
>>> >>
>>> >> 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
>>> >> >>> .
>>> >> >>>
>>> >> >>
>>> >>
>>>
>>

-- 
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/CAJReL37dhoGmUgtmb6o0_f4yekAjPzBQHfRD98%2B-kqb3fCdoZw%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 11925 bytes --]

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

end of thread, other threads:[~2019-11-12  1:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01 23:09 Conditional markdown parsing? 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
     [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

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