public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Wrapping sections of text with <div></div> in custom filter
@ 2023-05-24 20:51 H
       [not found] ` <2fc450a6-5a16-316c-02c8-8ef055bccd11-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-05-24 20:51 UTC (permalink / raw)
  To: Pandoc Mailing List

Using pandoc 3.1.2 and am trying my hand at writing my first writer to customize HTML output for a specific, predefined newsletter format.

The source document is written in markdown, contains headers of various levels, paragraphs of text, links to images and mail links. No lists, no tables and no code blocks.

The document is structured with an introductory section, multiple identically formatted sections and then a final section at the end. I need to wrap various portions of the structure with <div></div> at multiple levels in order to achieve the desired formatting. Some of the <div></div> tags need to wrap H1, H2, image, multiple paragraphs, other <div></div> tags wrap only one such item. In addition, most HTML tag need to have some predefined custom style information.

This output will be manually added to a certain newsletter editor in a CRM system and I cannot add any CSS information whatsoever, everything has to be structured as outlined above.

Since I am new to writing filters, I am looking for some suggestions how approach the <div></div> wrapping when multiple different HTML items need to be wrapped.

Thank you.

-- 
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/2fc450a6-5a16-316c-02c8-8ef055bccd11%40meddatainc.com.


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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found] ` <2fc450a6-5a16-316c-02c8-8ef055bccd11-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-05-24 23:20   ` H
       [not found]     ` <93e5b610-66a2-6ac7-1d53-8a04a8314249-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-05-24 23:20 UTC (permalink / raw)
  To: Pandoc Mailing List

On 05/24/2023 04:51 PM, H wrote:
> Using pandoc 3.1.2 and am trying my hand at writing my first writer to customize HTML output for a specific, predefined newsletter format.
>
> The source document is written in markdown, contains headers of various levels, paragraphs of text, links to images and mail links. No lists, no tables and no code blocks.
>
> The document is structured with an introductory section, multiple identically formatted sections and then a final section at the end. I need to wrap various portions of the structure with <div></div> at multiple levels in order to achieve the desired formatting. Some of the <div></div> tags need to wrap H1, H2, image, multiple paragraphs, other <div></div> tags wrap only one such item. In addition, most HTML tag need to have some predefined custom style information.
>
> This output will be manually added to a certain newsletter editor in a CRM system and I cannot add any CSS information whatsoever, everything has to be structured as outlined above.
>
> Since I am new to writing filters, I am looking for some suggestions how approach the <div></div> wrapping when multiple different HTML items need to be wrapped.
>
> Thank you.
>
I should add that one <div></div> pair may enclose H1, H2, image, and several paragraphs until the next H1 tag or end of document. Another <div></div> pair (within the just-mentioned pair) may enclose the image and several paragraphs, again until the next H1 tag (or end of document). There are some additional levels of <div> pairs but this describes the gist of it.

Suggestions welcome!

-- 
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/93e5b610-66a2-6ac7-1d53-8a04a8314249%40meddatainc.com.


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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]     ` <93e5b610-66a2-6ac7-1d53-8a04a8314249-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-05-25 10:42       ` Felix SOEDJEDE
       [not found]         ` <853c402b-d9ee-4c9d-8bae-15b20faf7194n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: Felix SOEDJEDE @ 2023-05-25 10:42 UTC (permalink / raw)
  To: pandoc-discuss


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

You could use Fenced divs: https://pandoc.org/MANUAL.html#divs-and-spans

You can put inside headers, paragraphs, code blocks, etc.


Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :

> On 05/24/2023 04:51 PM, H wrote:
> > Using pandoc 3.1.2 and am trying my hand at writing my first writer to 
> customize HTML output for a specific, predefined newsletter format.
> >
> > The source document is written in markdown, contains headers of various 
> levels, paragraphs of text, links to images and mail links. No lists, no 
> tables and no code blocks.
> >
> > The document is structured with an introductory section, multiple 
> identically formatted sections and then a final section at the end. I need 
> to wrap various portions of the structure with <div></div> at multiple 
> levels in order to achieve the desired formatting. Some of the <div></div> 
> tags need to wrap H1, H2, image, multiple paragraphs, other <div></div> 
> tags wrap only one such item. In addition, most HTML tag need to have some 
> predefined custom style information.
> >
> > This output will be manually added to a certain newsletter editor in a 
> CRM system and I cannot add any CSS information whatsoever, everything has 
> to be structured as outlined above.
> >
> > Since I am new to writing filters, I am looking for some suggestions how 
> approach the <div></div> wrapping when multiple different HTML items need 
> to be wrapped.
> >
> > Thank you.
> >
> I should add that one <div></div> pair may enclose H1, H2, image, and 
> several paragraphs until the next H1 tag or end of document. Another 
> <div></div> pair (within the just-mentioned pair) may enclose the image and 
> several paragraphs, again until the next H1 tag (or end of document). There 
> are some additional levels of <div> pairs but this describes the gist of it.
>
> Suggestions welcome!
>
>

-- 
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/853c402b-d9ee-4c9d-8bae-15b20faf7194n%40googlegroups.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]         ` <853c402b-d9ee-4c9d-8bae-15b20faf7194n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2023-05-25 19:36           ` H
       [not found]             ` <1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-05-25 19:36 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On May 25, 2023 6:42:49 AM EDT, Felix SOEDJEDE <soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>You could use Fenced divs:
>https://pandoc.org/MANUAL.html#divs-and-spans
>
>You can put inside headers, paragraphs, code blocks, etc.
>
>
>Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :
>
>> On 05/24/2023 04:51 PM, H wrote:
>> > Using pandoc 3.1.2 and am trying my hand at writing my first writer
>to 
>> customize HTML output for a specific, predefined newsletter format.
>> >
>> > The source document is written in markdown, contains headers of
>various 
>> levels, paragraphs of text, links to images and mail links. No lists,
>no 
>> tables and no code blocks.
>> >
>> > The document is structured with an introductory section, multiple 
>> identically formatted sections and then a final section at the end. I
>need 
>> to wrap various portions of the structure with <div></div> at
>multiple 
>> levels in order to achieve the desired formatting. Some of the
><div></div> 
>> tags need to wrap H1, H2, image, multiple paragraphs, other
><div></div> 
>> tags wrap only one such item. In addition, most HTML tag need to have
>some 
>> predefined custom style information.
>> >
>> > This output will be manually added to a certain newsletter editor
>in a 
>> CRM system and I cannot add any CSS information whatsoever,
>everything has 
>> to be structured as outlined above.
>> >
>> > Since I am new to writing filters, I am looking for some
>suggestions how 
>> approach the <div></div> wrapping when multiple different HTML items
>need 
>> to be wrapped.
>> >
>> > Thank you.
>> >
>> I should add that one <div></div> pair may enclose H1, H2, image, and
>
>> several paragraphs until the next H1 tag or end of document. Another 
>> <div></div> pair (within the just-mentioned pair) may enclose the
>image and 
>> several paragraphs, again until the next H1 tag (or end of document).
>There 
>> are some additional levels of <div> pairs but this describes the gist
>of it.
>>
>> Suggestions welcome!
>>
>>

I do not want to make any changes to the source markdown document, the appropriate processing needs to be done in my custom output HTML filter.

I am looking into the following (simplified) flow example:
- Add a <div> tag when encountering a H2 element.
- Add the corresponding </div> tag when encountering a H1 or H2 element or the end of the document.

-- 
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/1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0%40meddatainc.com.


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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]             ` <1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-05-25 20:38               ` 'William Lupton' via pandoc-discuss
       [not found]                 ` <CAEe_xxgNr8O73TNGgV5y=gwiLAKB3WFuX5a49Vv_RJDtojVcSQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: 'William Lupton' via pandoc-discuss @ 2023-05-25 20:38 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Have you considered the --sections-divs option (
https://pandoc.org/MANUAL.html#option--section-divs)?

For example, this markdown:

# A

## A1

## A2

# B

gives the following:

(1) pandoc section-divs.md

<h1 id="a">A</h1>
<h2 id="a1">A1</h2>
<h2 id="a2">A2</h2>
<h1 id="b">B</h1>

(2) pandoc section-divs.md --section-divs

<section id="a" class="level1">
<h1>A</h1>
<section id="a1" class="level2">
<h2>A1</h2>
</section>
<section id="a2" class="level2">
<h2>A2</h2>
</section>
</section>
<section id="b" class="level1">
<h1>B</h1>
</section>

(3) pandoc section-divs.md --section-divs --to=html4

<div id="a" class="section level1">
<h1>A</h1>
<div id="a1" class="section level2">
<h2>A1</h2>
</div>
<div id="a2" class="section level2">
<h2>A2</h2>
</div>
</div>
<div id="b" class="section level1">
<h1>B</h1>
</div>

On Thu, 25 May 2023 at 20:36, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:

> On May 25, 2023 6:42:49 AM EDT, Felix SOEDJEDE <soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> >You could use Fenced divs:
> >https://pandoc.org/MANUAL.html#divs-and-spans
> >
> >You can put inside headers, paragraphs, code blocks, etc.
> >
> >
> >Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :
> >
> >> On 05/24/2023 04:51 PM, H wrote:
> >> > Using pandoc 3.1.2 and am trying my hand at writing my first writer
> >to
> >> customize HTML output for a specific, predefined newsletter format.
> >> >
> >> > The source document is written in markdown, contains headers of
> >various
> >> levels, paragraphs of text, links to images and mail links. No lists,
> >no
> >> tables and no code blocks.
> >> >
> >> > The document is structured with an introductory section, multiple
> >> identically formatted sections and then a final section at the end. I
> >need
> >> to wrap various portions of the structure with <div></div> at
> >multiple
> >> levels in order to achieve the desired formatting. Some of the
> ><div></div>
> >> tags need to wrap H1, H2, image, multiple paragraphs, other
> ><div></div>
> >> tags wrap only one such item. In addition, most HTML tag need to have
> >some
> >> predefined custom style information.
> >> >
> >> > This output will be manually added to a certain newsletter editor
> >in a
> >> CRM system and I cannot add any CSS information whatsoever,
> >everything has
> >> to be structured as outlined above.
> >> >
> >> > Since I am new to writing filters, I am looking for some
> >suggestions how
> >> approach the <div></div> wrapping when multiple different HTML items
> >need
> >> to be wrapped.
> >> >
> >> > Thank you.
> >> >
> >> I should add that one <div></div> pair may enclose H1, H2, image, and
> >
> >> several paragraphs until the next H1 tag or end of document. Another
> >> <div></div> pair (within the just-mentioned pair) may enclose the
> >image and
> >> several paragraphs, again until the next H1 tag (or end of document).
> >There
> >> are some additional levels of <div> pairs but this describes the gist
> >of it.
> >>
> >> Suggestions welcome!
> >>
> >>
>
> I do not want to make any changes to the source markdown document, the
> appropriate processing needs to be done in my custom output HTML filter.
>
> I am looking into the following (simplified) flow example:
> - Add a <div> tag when encountering a H2 element.
> - Add the corresponding </div> tag when encountering a H1 or H2 element or
> the end of the document.
>
> --
> 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/1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0%40meddatainc.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/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                 ` <CAEe_xxgNr8O73TNGgV5y=gwiLAKB3WFuX5a49Vv_RJDtojVcSQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-05-26  0:31                   ` H
       [not found]                     ` <6d414734-e661-ae2d-68a1-4dfc9cb4f035-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-05-26  0:31 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On 05/25/2023 04:38 PM, 'William Lupton' via pandoc-discuss wrote:
> Have you considered the --sections-divs option (https://pandoc.org/MANUAL.html#option--section-divs)?
>
> For example, this markdown:
>
> # A
>
> ## A1
>
> ## A2
>
> # B
>
> gives the following:
>
> (1) pandoc section-divs.md
>
> <h1 id="a">A</h1>
> <h2 id="a1">A1</h2>
> <h2 id="a2">A2</h2>
> <h1 id="b">B</h1>
>
> (2) pandoc section-divs.md --section-divs
>
> <section id="a" class="level1">
> <h1>A</h1>
> <section id="a1" class="level2">
> <h2>A1</h2>
> </section>
> <section id="a2" class="level2">
> <h2>A2</h2>
> </section>
> </section>
> <section id="b" class="level1">
> <h1>B</h1>
> </section>
>
> (3) pandoc section-divs.md --section-divs --to=html4
>
> <div id="a" class="section level1">
> <h1>A</h1>
> <div id="a1" class="section level2">
> <h2>A1</h2>
> </div>
> <div id="a2" class="section level2">
> <h2>A2</h2>
> </div>
> </div>
> <div id="b" class="section level1">
> <h1>B</h1>
> </div>
>
> On Thu, 25 May 2023 at 20:36, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents@meddatainc.com>> wrote:
>
>     On May 25, 2023 6:42:49 AM EDT, Felix SOEDJEDE <soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <mailto:soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>     >You could use Fenced divs:
>     >https://pandoc.org/MANUAL.html#divs-and-spans
>     >
>     >You can put inside headers, paragraphs, code blocks, etc.
>     >
>     >
>     >Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :
>     >
>     >> On 05/24/2023 04:51 PM, H wrote:
>     >> > Using pandoc 3.1.2 and am trying my hand at writing my first writer
>     >to
>     >> customize HTML output for a specific, predefined newsletter format.
>     >> >
>     >> > The source document is written in markdown, contains headers of
>     >various
>     >> levels, paragraphs of text, links to images and mail links. No lists,
>     >no
>     >> tables and no code blocks.
>     >> >
>     >> > The document is structured with an introductory section, multiple
>     >> identically formatted sections and then a final section at the end. I
>     >need
>     >> to wrap various portions of the structure with <div></div> at
>     >multiple
>     >> levels in order to achieve the desired formatting. Some of the
>     ><div></div>
>     >> tags need to wrap H1, H2, image, multiple paragraphs, other
>     ><div></div>
>     >> tags wrap only one such item. In addition, most HTML tag need to have
>     >some
>     >> predefined custom style information.
>     >> >
>     >> > This output will be manually added to a certain newsletter editor
>     >in a
>     >> CRM system and I cannot add any CSS information whatsoever,
>     >everything has
>     >> to be structured as outlined above.
>     >> >
>     >> > Since I am new to writing filters, I am looking for some
>     >suggestions how
>     >> approach the <div></div> wrapping when multiple different HTML items
>     >need
>     >> to be wrapped.
>     >> >
>     >> > Thank you.
>     >> >
>     >> I should add that one <div></div> pair may enclose H1, H2, image, and
>     >
>     >> several paragraphs until the next H1 tag or end of document. Another
>     >> <div></div> pair (within the just-mentioned pair) may enclose the
>     >image and
>     >> several paragraphs, again until the next H1 tag (or end of document).
>     >There
>     >> are some additional levels of <div> pairs but this describes the gist
>     >of it.
>     >>
>     >> Suggestions welcome!
>     >>
>     >>
>
>     I do not want to make any changes to the source markdown document, the appropriate processing needs to be done in my custom output HTML filter.
>
>     I am looking into the following (simplified) flow example:
>     - Add a <div> tag when encountering a H2 element.
>     - Add the corresponding </div> tag when encountering a H1 or H2 element or the end of the document.
>
>     -- 
>     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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>     To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0%40meddatainc.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

It's somewhat close but I need to do additional customization. Where can I find the code this uses so I can look at it and use as a base for my own writer?

-- 
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/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                     ` <6d414734-e661-ae2d-68a1-4dfc9cb4f035-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-05-26  6:33                       ` 'William Lupton' via pandoc-discuss
       [not found]                         ` <CAEe_xxg9ExgK4WCNz6G=r=s4DSCs4CBPERcUV431yov2UmeO8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: 'William Lupton' via pandoc-discuss @ 2023-05-26  6:33 UTC (permalink / raw)
  To: pandoc-discuss

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

Good. From your original message:

> Some of the <div></div> tags need to wrap H1, H2, image, multiple
paragraphs, other <div></div> tags wrap only one such item. In addition,
most HTML tag need to have some predefined custom style information.

--section-divs covers some of this. For the rest, do you want to wrap all
images, or only some? If the latter, how will this be indicated in the
markdown? Similarly, how will the multiple paragraphs (that are to be
wrapped) be grouped?

The remaining wrapping logic can almost certainly be achieved via a lua
filter, and shouldn't require changes to the writer.

As for the styles, can the desired results be achieved via CSS?

On Fri, 26 May 2023, 01:31 H, <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:

> On 05/25/2023 04:38 PM, 'William Lupton' via pandoc-discuss wrote:
>
> Have you considered the --sections-divs option (
> https://pandoc.org/MANUAL.html#option--section-divs)?
>
> For example, this markdown:
>
> # A
>
> ## A1
>
> ## A2
>
> # B
>
> gives the following:
>
> (1) pandoc section-divs.md
>
> <h1 id="a">A</h1>
> <h2 id="a1">A1</h2>
> <h2 id="a2">A2</h2>
> <h1 id="b">B</h1>
>
> (2) pandoc section-divs.md --section-divs
>
> <section id="a" class="level1">
> <h1>A</h1>
> <section id="a1" class="level2">
> <h2>A1</h2>
> </section>
> <section id="a2" class="level2">
> <h2>A2</h2>
> </section>
> </section>
> <section id="b" class="level1">
> <h1>B</h1>
> </section>
>
> (3) pandoc section-divs.md --section-divs --to=html4
>
> <div id="a" class="section level1">
> <h1>A</h1>
> <div id="a1" class="section level2">
> <h2>A1</h2>
> </div>
> <div id="a2" class="section level2">
> <h2>A2</h2>
> </div>
> </div>
> <div id="b" class="section level1">
> <h1>B</h1>
> </div>
>
> On Thu, 25 May 2023 at 20:36, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>
>> On May 25, 2023 6:42:49 AM EDT, Felix SOEDJEDE <soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> wrote:
>> >You could use Fenced divs:
>> >https://pandoc.org/MANUAL.html#divs-and-spans
>> >
>> >You can put inside headers, paragraphs, code blocks, etc.
>> >
>> >
>> >Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :
>> >
>> >> On 05/24/2023 04:51 PM, H wrote:
>> >> > Using pandoc 3.1.2 and am trying my hand at writing my first writer
>> >to
>> >> customize HTML output for a specific, predefined newsletter format.
>> >> >
>> >> > The source document is written in markdown, contains headers of
>> >various
>> >> levels, paragraphs of text, links to images and mail links. No lists,
>> >no
>> >> tables and no code blocks.
>> >> >
>> >> > The document is structured with an introductory section, multiple
>> >> identically formatted sections and then a final section at the end. I
>> >need
>> >> to wrap various portions of the structure with <div></div> at
>> >multiple
>> >> levels in order to achieve the desired formatting. Some of the
>> ><div></div>
>> >> tags need to wrap H1, H2, image, multiple paragraphs, other
>> ><div></div>
>> >> tags wrap only one such item. In addition, most HTML tag need to have
>> >some
>> >> predefined custom style information.
>> >> >
>> >> > This output will be manually added to a certain newsletter editor
>> >in a
>> >> CRM system and I cannot add any CSS information whatsoever,
>> >everything has
>> >> to be structured as outlined above.
>> >> >
>> >> > Since I am new to writing filters, I am looking for some
>> >suggestions how
>> >> approach the <div></div> wrapping when multiple different HTML items
>> >need
>> >> to be wrapped.
>> >> >
>> >> > Thank you.
>> >> >
>> >> I should add that one <div></div> pair may enclose H1, H2, image, and
>> >
>> >> several paragraphs until the next H1 tag or end of document. Another
>> >> <div></div> pair (within the just-mentioned pair) may enclose the
>> >image and
>> >> several paragraphs, again until the next H1 tag (or end of document).
>> >There
>> >> are some additional levels of <div> pairs but this describes the gist
>> >of it.
>> >>
>> >> Suggestions welcome!
>> >>
>> >>
>>
>> I do not want to make any changes to the source markdown document, the
>> appropriate processing needs to be done in my custom output HTML filter.
>>
>> I am looking into the following (simplified) flow example:
>> - Add a <div> tag when encountering a H2 element.
>> - Add the corresponding </div> tag when encountering a H1 or H2 element
>> or the end of the document.
>>
>> --
>> 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/1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0%40meddatainc.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/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> It's somewhat close but I need to do additional customization. Where can I
> find the code this uses so I can look at it and use as a base for my own
> writer?
>
> --
> 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/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com
> <https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                         ` <CAEe_xxg9ExgK4WCNz6G=r=s4DSCs4CBPERcUV431yov2UmeO8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-05-26 19:43                           ` H
       [not found]                             ` <cee5298a-37c9-6e17-6370-eecda5d9d6fb-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-05-26 19:43 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On 05/26/2023 02:33 AM, 'William Lupton' via pandoc-discuss wrote:
> Good. From your original message:
>
> > Some of the <div></div> tags need to wrap H1, H2, image, multiple paragraphs, other <div></div> tags wrap only one such item. In addition, most HTML tag need to have some predefined custom style information.
>
> --section-divs covers some of this. For the rest, do you want to wrap all images, or only some? If the latter, how will this be indicated in the markdown? Similarly, how will the multiple paragraphs (that are to be wrapped) be grouped?
>
> The remaining wrapping logic can almost certainly be achieved via a lua filter, and shouldn't require changes to the writer.
>
> As for the styles, can the desired results be achieved via CSS?
>
> On Fri, 26 May 2023, 01:31 H, <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents@meddatainc.com>> wrote:
>
>     On 05/25/2023 04:38 PM, 'William Lupton' via pandoc-discuss wrote:
>>     Have you considered the --sections-divs option (https://pandoc.org/MANUAL.html#option--section-divs)?
>>
>>     For example, this markdown:
>>
>>     # A
>>
>>     ## A1
>>
>>     ## A2
>>
>>     # B
>>
>>     gives the following:
>>
>>     (1) pandoc section-divs.md
>>
>>     <h1 id="a">A</h1>
>>     <h2 id="a1">A1</h2>
>>     <h2 id="a2">A2</h2>
>>     <h1 id="b">B</h1>
>>
>>     (2) pandoc section-divs.md --section-divs
>>
>>     <section id="a" class="level1">
>>     <h1>A</h1>
>>     <section id="a1" class="level2">
>>     <h2>A1</h2>
>>     </section>
>>     <section id="a2" class="level2">
>>     <h2>A2</h2>
>>     </section>
>>     </section>
>>     <section id="b" class="level1">
>>     <h1>B</h1>
>>     </section>
>>
>>     (3) pandoc section-divs.md --section-divs --to=html4
>>
>>     <div id="a" class="section level1">
>>     <h1>A</h1>
>>     <div id="a1" class="section level2">
>>     <h2>A1</h2>
>>     </div>
>>     <div id="a2" class="section level2">
>>     <h2>A2</h2>
>>     </div>
>>     </div>
>>     <div id="b" class="section level1">
>>     <h1>B</h1>
>>     </div>
>>
>>     On Thu, 25 May 2023 at 20:36, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents@meddatainc.com>> wrote:
>>
>>         On May 25, 2023 6:42:49 AM EDT, Felix SOEDJEDE <soefelix@gmail.com <mailto:soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>>         >You could use Fenced divs:
>>         >https://pandoc.org/MANUAL.html#divs-and-spans
>>         >
>>         >You can put inside headers, paragraphs, code blocks, etc.
>>         >
>>         >
>>         >Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :
>>         >
>>         >> On 05/24/2023 04:51 PM, H wrote:
>>         >> > Using pandoc 3.1.2 and am trying my hand at writing my first writer
>>         >to
>>         >> customize HTML output for a specific, predefined newsletter format.
>>         >> >
>>         >> > The source document is written in markdown, contains headers of
>>         >various
>>         >> levels, paragraphs of text, links to images and mail links. No lists,
>>         >no
>>         >> tables and no code blocks.
>>         >> >
>>         >> > The document is structured with an introductory section, multiple
>>         >> identically formatted sections and then a final section at the end. I
>>         >need
>>         >> to wrap various portions of the structure with <div></div> at
>>         >multiple
>>         >> levels in order to achieve the desired formatting. Some of the
>>         ><div></div>
>>         >> tags need to wrap H1, H2, image, multiple paragraphs, other
>>         ><div></div>
>>         >> tags wrap only one such item. In addition, most HTML tag need to have
>>         >some
>>         >> predefined custom style information.
>>         >> >
>>         >> > This output will be manually added to a certain newsletter editor
>>         >in a
>>         >> CRM system and I cannot add any CSS information whatsoever,
>>         >everything has
>>         >> to be structured as outlined above.
>>         >> >
>>         >> > Since I am new to writing filters, I am looking for some
>>         >suggestions how
>>         >> approach the <div></div> wrapping when multiple different HTML items
>>         >need
>>         >> to be wrapped.
>>         >> >
>>         >> > Thank you.
>>         >> >
>>         >> I should add that one <div></div> pair may enclose H1, H2, image, and
>>         >
>>         >> several paragraphs until the next H1 tag or end of document. Another
>>         >> <div></div> pair (within the just-mentioned pair) may enclose the
>>         >image and
>>         >> several paragraphs, again until the next H1 tag (or end of document).
>>         >There
>>         >> are some additional levels of <div> pairs but this describes the gist
>>         >of it.
>>         >>
>>         >> Suggestions welcome!
>>         >>
>>         >>
>>
>>         I do not want to make any changes to the source markdown document, the appropriate processing needs to be done in my custom output HTML filter.
>>
>>         I am looking into the following (simplified) flow example:
>>         - Add a <div> tag when encountering a H2 element.
>>         - Add the corresponding </div> tag when encountering a H1 or H2 element or the end of the document.
>>
>>         -- 
>>         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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>         To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0%40meddatainc.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>     To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
>     It's somewhat close but I need to do additional customization. Where can I find the code this uses so I can look at it and use as a base for my own writer?
>
>     -- 
>     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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>     To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com <https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com?utm_medium=email&utm_source=footer>.
>
> -- 
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com?utm_medium=email&utm_source=footer>.

No CSS (I had mentioned that in a previous message), also no modifications to the markdown file so the entire interpretation of layout, adding style information etc. needs to be in my custom PDF writer. This custom writer will - obviously - be specific for this single dedicated use by myself.

Any pointers (links, code fragments to look at etc.) as to how I should traverse the tree to be able to output my custom PDF would be greatly appreciated since this will be my first pandoc writer.

-- 
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/cee5298a-37c9-6e17-6370-eecda5d9d6fb%40meddatainc.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                             ` <cee5298a-37c9-6e17-6370-eecda5d9d6fb-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-05-26 21:01                               ` 'William Lupton' via pandoc-discuss
  2023-05-29  0:50                               ` H
  1 sibling, 0 replies; 22+ messages in thread
From: 'William Lupton' via pandoc-discuss @ 2023-05-26 21:01 UTC (permalink / raw)
  To: pandoc-discuss

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

How will the styling be added? Directly via 'style' attributes in HTML
elements or by some other mechanism? If via style attributes then you might
as well use CSS (which could be embedded in the output document,
potentially via use of a custom template). Perhaps you could give a short
example of what your ideal HTML would look like?

Sorry not (yet) to have answered your question directly, but I still don't
understand why it's necessary to create a custom writer.

BTW, from your other questions (which led to John sharing his djot writer)
I assume that you intend to use lua rather than in Haskell. Is that
correct?

On Fri, 26 May 2023, 20:43 H, <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:

> On 05/26/2023 02:33 AM, 'William Lupton' via pandoc-discuss wrote:
>
> Good. From your original message:
>
> > Some of the <div></div> tags need to wrap H1, H2, image, multiple
> paragraphs, other <div></div> tags wrap only one such item. In addition,
> most HTML tag need to have some predefined custom style information.
>
> --section-divs covers some of this. For the rest, do you want to wrap all
> images, or only some? If the latter, how will this be indicated in the
> markdown? Similarly, how will the multiple paragraphs (that are to be
> wrapped) be grouped?
>
> The remaining wrapping logic can almost certainly be achieved via a lua
> filter, and shouldn't require changes to the writer.
>
> As for the styles, can the desired results be achieved via CSS?
>
> On Fri, 26 May 2023, 01:31 H, <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>
>> On 05/25/2023 04:38 PM, 'William Lupton' via pandoc-discuss wrote:
>>
>> Have you considered the --sections-divs option (
>> https://pandoc.org/MANUAL.html#option--section-divs)?
>>
>> For example, this markdown:
>>
>> # A
>>
>> ## A1
>>
>> ## A2
>>
>> # B
>>
>> gives the following:
>>
>> (1) pandoc section-divs.md
>>
>> <h1 id="a">A</h1>
>> <h2 id="a1">A1</h2>
>> <h2 id="a2">A2</h2>
>> <h1 id="b">B</h1>
>>
>> (2) pandoc section-divs.md --section-divs
>>
>> <section id="a" class="level1">
>> <h1>A</h1>
>> <section id="a1" class="level2">
>> <h2>A1</h2>
>> </section>
>> <section id="a2" class="level2">
>> <h2>A2</h2>
>> </section>
>> </section>
>> <section id="b" class="level1">
>> <h1>B</h1>
>> </section>
>>
>> (3) pandoc section-divs.md --section-divs --to=html4
>>
>> <div id="a" class="section level1">
>> <h1>A</h1>
>> <div id="a1" class="section level2">
>> <h2>A1</h2>
>> </div>
>> <div id="a2" class="section level2">
>> <h2>A2</h2>
>> </div>
>> </div>
>> <div id="b" class="section level1">
>> <h1>B</h1>
>> </div>
>>
>> On Thu, 25 May 2023 at 20:36, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>>
>>> On May 25, 2023 6:42:49 AM EDT, Felix SOEDJEDE <soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>> wrote:
>>> >You could use Fenced divs:
>>> >https://pandoc.org/MANUAL.html#divs-and-spans
>>> >
>>> >You can put inside headers, paragraphs, code blocks, etc.
>>> >
>>> >
>>> >Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :
>>> >
>>> >> On 05/24/2023 04:51 PM, H wrote:
>>> >> > Using pandoc 3.1.2 and am trying my hand at writing my first writer
>>> >to
>>> >> customize HTML output for a specific, predefined newsletter format.
>>> >> >
>>> >> > The source document is written in markdown, contains headers of
>>> >various
>>> >> levels, paragraphs of text, links to images and mail links. No lists,
>>> >no
>>> >> tables and no code blocks.
>>> >> >
>>> >> > The document is structured with an introductory section, multiple
>>> >> identically formatted sections and then a final section at the end. I
>>> >need
>>> >> to wrap various portions of the structure with <div></div> at
>>> >multiple
>>> >> levels in order to achieve the desired formatting. Some of the
>>> ><div></div>
>>> >> tags need to wrap H1, H2, image, multiple paragraphs, other
>>> ><div></div>
>>> >> tags wrap only one such item. In addition, most HTML tag need to have
>>> >some
>>> >> predefined custom style information.
>>> >> >
>>> >> > This output will be manually added to a certain newsletter editor
>>> >in a
>>> >> CRM system and I cannot add any CSS information whatsoever,
>>> >everything has
>>> >> to be structured as outlined above.
>>> >> >
>>> >> > Since I am new to writing filters, I am looking for some
>>> >suggestions how
>>> >> approach the <div></div> wrapping when multiple different HTML items
>>> >need
>>> >> to be wrapped.
>>> >> >
>>> >> > Thank you.
>>> >> >
>>> >> I should add that one <div></div> pair may enclose H1, H2, image, and
>>> >
>>> >> several paragraphs until the next H1 tag or end of document. Another
>>> >> <div></div> pair (within the just-mentioned pair) may enclose the
>>> >image and
>>> >> several paragraphs, again until the next H1 tag (or end of document).
>>> >There
>>> >> are some additional levels of <div> pairs but this describes the gist
>>> >of it.
>>> >>
>>> >> Suggestions welcome!
>>> >>
>>> >>
>>>
>>> I do not want to make any changes to the source markdown document, the
>>> appropriate processing needs to be done in my custom output HTML filter.
>>>
>>> I am looking into the following (simplified) flow example:
>>> - Add a <div> tag when encountering a H2 element.
>>> - Add the corresponding </div> tag when encountering a H1 or H2 element
>>> or the end of the document.
>>>
>>> --
>>> 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/1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0%40meddatainc.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/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> It's somewhat close but I need to do additional customization. Where can
>> I find the code this uses so I can look at it and use as a base for my own
>> writer?
>> --
>> 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/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com
>> <https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com
> <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> No CSS (I had mentioned that in a previous message), also no modifications
> to the markdown file so the entire interpretation of layout, adding style
> information etc. needs to be in my custom PDF writer. This custom writer
> will - obviously - be specific for this single dedicated use by myself.
>
> Any pointers (links, code fragments to look at etc.) as to how I should
> traverse the tree to be able to output my custom PDF would be greatly
> appreciated since this will be my first pandoc writer.
>
> --
> 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/cee5298a-37c9-6e17-6370-eecda5d9d6fb%40meddatainc.com
> <https://groups.google.com/d/msgid/pandoc-discuss/cee5298a-37c9-6e17-6370-eecda5d9d6fb%40meddatainc.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEe_xxiHuhXHPnShyPPA_L9O4ffvg2mU5YuKEg8Ops4eKMqLXQ%40mail.gmail.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                             ` <cee5298a-37c9-6e17-6370-eecda5d9d6fb-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  2023-05-26 21:01                               ` 'William Lupton' via pandoc-discuss
@ 2023-05-29  0:50                               ` H
       [not found]                                 ` <4c58dad0-bd86-608e-2d68-74bd6f2f808b-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  1 sibling, 1 reply; 22+ messages in thread
From: H @ 2023-05-29  0:50 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On 05/26/2023 03:43 PM, H wrote:
> On 05/26/2023 02:33 AM, 'William Lupton' via pandoc-discuss wrote:
>> Good. From your original message:
>>
>> > Some of the <div></div> tags need to wrap H1, H2, image, multiple paragraphs, other <div></div> tags wrap only one such item. In addition, most HTML tag need to have some predefined custom style information.
>>
>> --section-divs covers some of this. For the rest, do you want to wrap all images, or only some? If the latter, how will this be indicated in the markdown? Similarly, how will the multiple paragraphs (that are to be wrapped) be grouped?
>>
>> The remaining wrapping logic can almost certainly be achieved via a lua filter, and shouldn't require changes to the writer.
>>
>> As for the styles, can the desired results be achieved via CSS?
>>
>> On Fri, 26 May 2023, 01:31 H, <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents@meddatainc.com>> wrote:
>>
>>     On 05/25/2023 04:38 PM, 'William Lupton' via pandoc-discuss wrote:
>>>     Have you considered the --sections-divs option (https://pandoc.org/MANUAL.html#option--section-divs)?
>>>
>>>     For example, this markdown:
>>>
>>>     # A
>>>
>>>     ## A1
>>>
>>>     ## A2
>>>
>>>     # B
>>>
>>>     gives the following:
>>>
>>>     (1) pandoc section-divs.md
>>>
>>>     <h1 id="a">A</h1>
>>>     <h2 id="a1">A1</h2>
>>>     <h2 id="a2">A2</h2>
>>>     <h1 id="b">B</h1>
>>>
>>>     (2) pandoc section-divs.md --section-divs
>>>
>>>     <section id="a" class="level1">
>>>     <h1>A</h1>
>>>     <section id="a1" class="level2">
>>>     <h2>A1</h2>
>>>     </section>
>>>     <section id="a2" class="level2">
>>>     <h2>A2</h2>
>>>     </section>
>>>     </section>
>>>     <section id="b" class="level1">
>>>     <h1>B</h1>
>>>     </section>
>>>
>>>     (3) pandoc section-divs.md --section-divs --to=html4
>>>
>>>     <div id="a" class="section level1">
>>>     <h1>A</h1>
>>>     <div id="a1" class="section level2">
>>>     <h2>A1</h2>
>>>     </div>
>>>     <div id="a2" class="section level2">
>>>     <h2>A2</h2>
>>>     </div>
>>>     </div>
>>>     <div id="b" class="section level1">
>>>     <h1>B</h1>
>>>     </div>
>>>
>>>     On Thu, 25 May 2023 at 20:36, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org>> wrote:
>>>
>>>         On May 25, 2023 6:42:49 AM EDT, Felix SOEDJEDE <soefelix@gmail.com <mailto:soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>>>         >You could use Fenced divs:
>>>         >https://pandoc.org/MANUAL.html#divs-and-spans
>>>         >
>>>         >You can put inside headers, paragraphs, code blocks, etc.
>>>         >
>>>         >
>>>         >Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :
>>>         >
>>>         >> On 05/24/2023 04:51 PM, H wrote:
>>>         >> > Using pandoc 3.1.2 and am trying my hand at writing my first writer
>>>         >to
>>>         >> customize HTML output for a specific, predefined newsletter format.
>>>         >> >
>>>         >> > The source document is written in markdown, contains headers of
>>>         >various
>>>         >> levels, paragraphs of text, links to images and mail links. No lists,
>>>         >no
>>>         >> tables and no code blocks.
>>>         >> >
>>>         >> > The document is structured with an introductory section, multiple
>>>         >> identically formatted sections and then a final section at the end. I
>>>         >need
>>>         >> to wrap various portions of the structure with <div></div> at
>>>         >multiple
>>>         >> levels in order to achieve the desired formatting. Some of the
>>>         ><div></div>
>>>         >> tags need to wrap H1, H2, image, multiple paragraphs, other
>>>         ><div></div>
>>>         >> tags wrap only one such item. In addition, most HTML tag need to have
>>>         >some
>>>         >> predefined custom style information.
>>>         >> >
>>>         >> > This output will be manually added to a certain newsletter editor
>>>         >in a
>>>         >> CRM system and I cannot add any CSS information whatsoever,
>>>         >everything has
>>>         >> to be structured as outlined above.
>>>         >> >
>>>         >> > Since I am new to writing filters, I am looking for some
>>>         >suggestions how
>>>         >> approach the <div></div> wrapping when multiple different HTML items
>>>         >need
>>>         >> to be wrapped.
>>>         >> >
>>>         >> > Thank you.
>>>         >> >
>>>         >> I should add that one <div></div> pair may enclose H1, H2, image, and
>>>         >
>>>         >> several paragraphs until the next H1 tag or end of document. Another
>>>         >> <div></div> pair (within the just-mentioned pair) may enclose the
>>>         >image and
>>>         >> several paragraphs, again until the next H1 tag (or end of document).
>>>         >There
>>>         >> are some additional levels of <div> pairs but this describes the gist
>>>         >of it.
>>>         >>
>>>         >> Suggestions welcome!
>>>         >>
>>>         >>
>>>
>>>         I do not want to make any changes to the source markdown document, the appropriate processing needs to be done in my custom output HTML filter.
>>>
>>>         I am looking into the following (simplified) flow example:
>>>         - Add a <div> tag when encountering a H2 element.
>>>         - Add the corresponding </div> tag when encountering a H1 or H2 element or the end of the document.
>>>
>>>         -- 
>>>         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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>         To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0%40meddatainc.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>     To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>
>>     It's somewhat close but I need to do additional customization. Where can I find the code this uses so I can look at it and use as a base for my own writer?
>>
>>     -- 
>>     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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>     To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com <https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com?utm_medium=email&utm_source=footer>.
>>
>> -- 
>> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> No CSS (I had mentioned that in a previous message), also no modifications to the markdown file so the entire interpretation of layout, adding style information etc. needs to be in my custom PDF writer. This custom writer will - obviously - be specific for this single dedicated use by myself.
>
> Any pointers (links, code fragments to look at etc.) as to how I should traverse the tree to be able to output my custom PDF would be greatly appreciated since this will be my first pandoc writer.
>
I am making some progress working on my custom writer for my desired html output layout. I am using the 3.0 syntax where the output function looks like

Writer.Pandoc = function(doc)
    return Writer.Blocks(doc.blocks)
end

At the start of my document I also have

Writer = pandoc.scaffolding.Writer

with customization added for inlines and blocks added.

In the Writer.Pandoc function above, is there a way I can see exactly in which order the document is evaluated? I am interested in exploring traverse = 'topdown' vs. traverse = 'typewise' as I think the topdown traversal will be required to add the necessary <div> and </div> in the correct locations to my final document.

Again, please bear in mind that I will do /all/ processing in this my custom lua writer.

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/4c58dad0-bd86-608e-2d68-74bd6f2f808b%40meddatainc.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                 ` <4c58dad0-bd86-608e-2d68-74bd6f2f808b-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-05-29  4:31                                   ` H
       [not found]                                     ` <F41D20AD-EDDD-4AF4-A9AD-AAB8581086BF-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-05-29  4:31 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On May 28, 2023 8:50:56 PM EDT, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>On 05/26/2023 03:43 PM, H wrote:
>> On 05/26/2023 02:33 AM, 'William Lupton' via pandoc-discuss wrote:
>>> Good. From your original message:
>>>
>>> > Some of the <div></div> tags need to wrap H1, H2, image, multiple
>paragraphs, other <div></div> tags wrap only one such item. In
>addition, most HTML tag need to have some predefined custom style
>information.
>>>
>>> --section-divs covers some of this. For the rest, do you want to
>wrap all images, or only some? If the latter, how will this be
>indicated in the markdown? Similarly, how will the multiple paragraphs
>(that are to be wrapped) be grouped?
>>>
>>> The remaining wrapping logic can almost certainly be achieved via a
>lua filter, and shouldn't require changes to the writer.
>>>
>>> As for the styles, can the desired results be achieved via CSS?
>>>
>>> On Fri, 26 May 2023, 01:31 H, <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org
><mailto:agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org>> wrote:
>>>
>>>     On 05/25/2023 04:38 PM, 'William Lupton' via pandoc-discuss
>wrote:
>>>>     Have you considered the --sections-divs option
>(https://pandoc.org/MANUAL.html#option--section-divs)?
>>>>
>>>>     For example, this markdown:
>>>>
>>>>     # A
>>>>
>>>>     ## A1
>>>>
>>>>     ## A2
>>>>
>>>>     # B
>>>>
>>>>     gives the following:
>>>>
>>>>     (1) pandoc section-divs.md
>>>>
>>>>     <h1 id="a">A</h1>
>>>>     <h2 id="a1">A1</h2>
>>>>     <h2 id="a2">A2</h2>
>>>>     <h1 id="b">B</h1>
>>>>
>>>>     (2) pandoc section-divs.md --section-divs
>>>>
>>>>     <section id="a" class="level1">
>>>>     <h1>A</h1>
>>>>     <section id="a1" class="level2">
>>>>     <h2>A1</h2>
>>>>     </section>
>>>>     <section id="a2" class="level2">
>>>>     <h2>A2</h2>
>>>>     </section>
>>>>     </section>
>>>>     <section id="b" class="level1">
>>>>     <h1>B</h1>
>>>>     </section>
>>>>
>>>>     (3) pandoc section-divs.md --section-divs --to=html4
>>>>
>>>>     <div id="a" class="section level1">
>>>>     <h1>A</h1>
>>>>     <div id="a1" class="section level2">
>>>>     <h2>A1</h2>
>>>>     </div>
>>>>     <div id="a2" class="section level2">
>>>>     <h2>A2</h2>
>>>>     </div>
>>>>     </div>
>>>>     <div id="b" class="section level1">
>>>>     <h1>B</h1>
>>>>     </div>
>>>>
>>>>     On Thu, 25 May 2023 at 20:36, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org
><mailto:agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org>> wrote:
>>>>
>>>>         On May 25, 2023 6:42:49 AM EDT, Felix SOEDJEDE
><soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <mailto:soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>>>>         >You could use Fenced divs:
>>>>         >https://pandoc.org/MANUAL.html#divs-and-spans
>>>>         >
>>>>         >You can put inside headers, paragraphs, code blocks, etc.
>>>>         >
>>>>         >
>>>>         >Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :
>>>>         >
>>>>         >> On 05/24/2023 04:51 PM, H wrote:
>>>>         >> > Using pandoc 3.1.2 and am trying my hand at writing my
>first writer
>>>>         >to
>>>>         >> customize HTML output for a specific, predefined
>newsletter format.
>>>>         >> >
>>>>         >> > The source document is written in markdown, contains
>headers of
>>>>         >various
>>>>         >> levels, paragraphs of text, links to images and mail
>links. No lists,
>>>>         >no
>>>>         >> tables and no code blocks.
>>>>         >> >
>>>>         >> > The document is structured with an introductory
>section, multiple
>>>>         >> identically formatted sections and then a final section
>at the end. I
>>>>         >need
>>>>         >> to wrap various portions of the structure with
><div></div> at
>>>>         >multiple
>>>>         >> levels in order to achieve the desired formatting. Some
>of the
>>>>         ><div></div>
>>>>         >> tags need to wrap H1, H2, image, multiple paragraphs,
>other
>>>>         ><div></div>
>>>>         >> tags wrap only one such item. In addition, most HTML tag
>need to have
>>>>         >some
>>>>         >> predefined custom style information.
>>>>         >> >
>>>>         >> > This output will be manually added to a certain
>newsletter editor
>>>>         >in a
>>>>         >> CRM system and I cannot add any CSS information
>whatsoever,
>>>>         >everything has
>>>>         >> to be structured as outlined above.
>>>>         >> >
>>>>         >> > Since I am new to writing filters, I am looking for
>some
>>>>         >suggestions how
>>>>         >> approach the <div></div> wrapping when multiple
>different HTML items
>>>>         >need
>>>>         >> to be wrapped.
>>>>         >> >
>>>>         >> > Thank you.
>>>>         >> >
>>>>         >> I should add that one <div></div> pair may enclose H1,
>H2, image, and
>>>>         >
>>>>         >> several paragraphs until the next H1 tag or end of
>document. Another
>>>>         >> <div></div> pair (within the just-mentioned pair) may
>enclose the
>>>>         >image and
>>>>         >> several paragraphs, again until the next H1 tag (or end
>of document).
>>>>         >There
>>>>         >> are some additional levels of <div> pairs but this
>describes the gist
>>>>         >of it.
>>>>         >>
>>>>         >> Suggestions welcome!
>>>>         >>
>>>>         >>
>>>>
>>>>         I do not want to make any changes to the source markdown
>document, the appropriate processing needs to be done in my custom
>output HTML filter.
>>>>
>>>>         I am looking into the following (simplified) flow example:
>>>>         - Add a <div> tag when encountering a H2 element.
>>>>         - Add the corresponding </div> tag when encountering a H1
>or H2 element or the end of the document.
>>>>
>>>>         -- 
>>>>         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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
><mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>         To view this discussion on the web visit
>https://groups.google.com/d/msgid/pandoc-discuss/1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0%40meddatainc.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
><mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>     To view this discussion on the web visit
>https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com
><https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>>
>>>     It's somewhat close but I need to do additional customization.
>Where can I find the code this uses so I can look at it and use as a
>base for my own writer?
>>>
>>>     -- 
>>>     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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
><mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>     To view this discussion on the web visit
>https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com
><https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com?utm_medium=email&utm_source=footer>.
>>>
>>> -- 
>>> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
><mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>> To view this discussion on the web visit
>https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com
><https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>
>> No CSS (I had mentioned that in a previous message), also no
>modifications to the markdown file so the entire interpretation of
>layout, adding style information etc. needs to be in my custom PDF
>writer. This custom writer will - obviously - be specific for this
>single dedicated use by myself.
>>
>> Any pointers (links, code fragments to look at etc.) as to how I
>should traverse the tree to be able to output my custom PDF would be
>greatly appreciated since this will be my first pandoc writer.
>>
>I am making some progress working on my custom writer for my desired
>html output layout. I am using the 3.0 syntax where the output function
>looks like
>
>Writer.Pandoc = function(doc)
>    return Writer.Blocks(doc.blocks)
>end
>
>At the start of my document I also have
>
>Writer = pandoc.scaffolding.Writer
>
>with customization added for inlines and blocks added.
>
>In the Writer.Pandoc function above, is there a way I can see exactly
>in which order the document is evaluated? I am interested in exploring
>traverse = 'topdown' vs. traverse = 'typewise' as I think the topdown
>traversal will be required to add the necessary <div> and </div> in the
>correct locations to my final document.
>
>Again, please bear in mind that I will do /all/ processing in this my
>custom lua writer.
>
>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/4c58dad0-bd86-608e-2d68-74bd6f2f808b%40meddatainc.com.

Upon further reading, it looks like the traverse directive might only be applicable to filters when the AST is being processed 

Is this correct? If so, is there anyway I can view the traversal processing sequence in my filter when I am writing and debugging it?

-- 
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/F41D20AD-EDDD-4AF4-A9AD-AAB8581086BF%40meddatainc.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                     ` <F41D20AD-EDDD-4AF4-A9AD-AAB8581086BF-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-05-30 18:30                                       ` H
       [not found]                                         ` <574fbf9f-c1b8-711a-f14a-3acd75cbf634-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-05-30 18:30 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On 05/29/2023 12:31 AM, H wrote:
> On May 28, 2023 8:50:56 PM EDT, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>
>     On 05/26/2023 03:43 PM, H wrote:
>>     On 05/26/2023 02:33 AM, 'William Lupton' via pandoc-discuss wrote:
>>>     Good. From your original message:
>>>
>>>     > Some of the <div></div> tags need to wrap H1, H2, image, multiple paragraphs, other <div></div> tags wrap only one such item. In addition, most HTML tag need to have some predefined custom style information.
>>>
>>>     --section-divs covers some of this. For the rest, do you want to wrap all images, or only some? If the latter, how will this be indicated in the markdown? Similarly, how will the multiple paragraphs (that are to be wrapped) be grouped?
>>>
>>>     The remaining wrapping logic can almost certainly be achieved via a lua filter, and shouldn't require changes to the writer.
>>>
>>>     As for the styles, can the desired results be achieved via CSS?
>>>
>>>     On Fri, 26 May 2023, 01:31 H, <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents@meddatainc.com>> wrote:
>>>
>>>         On 05/25/2023 04:38 PM, 'William Lupton' via pandoc-discuss wrote:
>>>>         Have you considered the --sections-divs option (https://pandoc.org/MANUAL.html#option--section-divs)?
>>>>
>>>>         For example, this markdown:
>>>>
>>>>         # A
>>>>
>>>>         ## A1
>>>>
>>>>         ## A2
>>>>
>>>>         # B
>>>>
>>>>         gives the following:
>>>>
>>>>         (1) pandoc section-divs.md
>>>>
>>>>         <h1 id="a">A</h1>
>>>>         <h2 id="a1">A1</h2>
>>>>         <h2 id="a2">A2</h2>
>>>>         <h1 id="b">B</h1>
>>>>
>>>>         (2) pandoc section-divs.md --section-divs
>>>>
>>>>         <section id="a" class="level1">
>>>>         <h1>A</h1>
>>>>         <section id="a1" class="level2">
>>>>         <h2>A1</h2>
>>>>         </section>
>>>>         <section id="a2" class="level2">
>>>>         <h2>A2</h2>
>>>>         </section>
>>>>         </section>
>>>>         <section id="b" class="level1">
>>>>         <h1>B</h1>
>>>>         </section>
>>>>
>>>>         (3) pandoc section-divs.md --section-divs --to=html4
>>>>
>>>>         <div id="a" class="section level1">
>>>>         <h1>A</h1>
>>>>         <div id="a1" class="section level2">
>>>>         <h2>A1</h2>
>>>>         </div>
>>>>         <div id="a2" class="section level2">
>>>>         <h2>A2</h2>
>>>>         </div>
>>>>         </div>
>>>>         <div id="b" class="section level1">
>>>>         <h1>B</h1>
>>>>         </div>
>>>>
>>>>         On Thu, 25 May 2023 at 20:36, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org>> wrote:
>>>>
>>>>             On May 25, 2023 6:42:49 AM EDT, Felix SOEDJEDE <soefelix@gmail.com <mailto:soefelix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>>>>             >You could use Fenced divs:
>>>>             >https://pandoc.org/MANUAL.html#divs-and-spans
>>>>             >
>>>>             >You can put inside headers, paragraphs, code blocks, etc.
>>>>             >
>>>>             >
>>>>             >Le jeudi 25 mai 2023 à 01:20:09 UTC+2, H a écrit :
>>>>             >
>>>>             >> On 05/24/2023 04:51 PM, H wrote:
>>>>             >> > Using pandoc 3.1.2 and am trying my hand at writing my first writer
>>>>             >to
>>>>             >> customize HTML output for a specific, predefined newsletter format.
>>>>             >> >
>>>>             >> > The source document is written in markdown, contains headers of
>>>>             >various
>>>>             >> levels, paragraphs of text, links to images and mail links. No lists,
>>>>             >no
>>>>             >> tables and no code blocks.
>>>>             >> >
>>>>             >> > The document is structured with an introductory section, multiple
>>>>             >> identically formatted sections and then a final section at the end. I
>>>>             >need
>>>>             >> to wrap various portions of the structure with <div></div> at
>>>>             >multiple
>>>>             >> levels in order to achieve the desired formatting. Some of the
>>>>             ><div></div>
>>>>             >> tags need to wrap H1, H2, image, multiple paragraphs, other
>>>>             ><div></div>
>>>>             >> tags wrap only one such item. In addition, most HTML tag need to have
>>>>             >some
>>>>             >> predefined custom style information.
>>>>             >> >
>>>>             >> > This output will be manually added to a certain newsletter editor
>>>>             >in a
>>>>             >> CRM system and I cannot add any CSS information whatsoever,
>>>>             >everything has
>>>>             >> to be structured as outlined above.
>>>>             >> >
>>>>             >> > Since I am new to writing filters, I am looking for some
>>>>             >suggestions how
>>>>             >> approach the <div></div> wrapping when multiple different HTML items
>>>>             >need
>>>>             >> to be wrapped.
>>>>             >> >
>>>>             >> > Thank you.
>>>>             >> >
>>>>             >> I should add that one <div></div> pair may enclose H1, H2, image, and
>>>>             >
>>>>             >> several paragraphs until the next H1 tag or end of document. Another
>>>>             >> <div></div> pair (within the just-mentioned pair) may enclose the
>>>>             >image and
>>>>             >> several paragraphs, again until the next H1 tag (or end of document).
>>>>             >There
>>>>             >> are some additional levels of <div> pairs but this describes the gist
>>>>             >of it.
>>>>             >>
>>>>             >> Suggestions welcome!
>>>>             >>
>>>>             >>
>>>>
>>>>             I do not want to make any changes to the source markdown document, the appropriate processing needs to be done in my custom output HTML filter.
>>>>
>>>>             I am looking into the following (simplified) flow example:
>>>>             - Add a <div> tag when encountering a H2 element.
>>>>             - Add the corresponding </div> tag when encountering a H1 or H2 element or the end of the document.
>>>>
>>>>             -- 
>>>>             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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>             To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0%40meddatainc.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>         To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgNr8O73TNGgV5y%3DgwiLAKB3WFuX5a49Vv_RJDtojVcSQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>>
>>>         It's somewhat close but I need to do additional customization. Where can I find the code this uses so I can look at it and use as a base for my own writer?
>>>
>>>         -- 
>>>         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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>         To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com <https://groups.google.com/d/msgid/pandoc-discuss/6d414734-e661-ae2d-68a1-4dfc9cb4f035%40meddatainc.com?utm_medium=email&utm_source=footer>.
>>>
>>>     -- 
>>>     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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>     To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxg9ExgK4WCNz6G%3Dr%3Ds4DSCs4CBPERcUV431yov2UmeO8w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>
>>     No CSS (I had mentioned that in a previous message), also no modifications to the markdown file so the entire interpretation of layout, adding style information etc. needs to be in my custom PDF writer. This custom writer will - obviously - be specific for this single dedicated use by myself.
>>
>>     Any pointers (links, code fragments to look at etc.) as to how I should traverse the tree to be able to output my custom PDF would be greatly appreciated since this will be my first pandoc writer.
>>
>     I am making some progress working on my custom writer for my desired html output layout. I am using the 3.0 syntax where the output function looks like
>
>     Writer.Pandoc = function(doc)
>         return Writer.Blocks(doc.blocks)
>     end
>
>     At the start of my document I also have
>
>     Writer = pandoc.scaffolding.Writer
>
>     with customization added for inlines and blocks added.
>
>     In the Writer.Pandoc function above, is there a way I can see exactly in which order the document is evaluated? I am interested in exploring traverse = 'topdown' vs. traverse = 'typewise' as I think the topdown traversal will be required to add the necessary <div> and </div> in the correct locations to my final document.
>
>     Again, please bear in mind that I will do /all/ processing in this my custom lua writer.
>
>     Thanks.
>
>
> Upon further reading, it looks like the traverse directive might only be applicable to filters when the AST is being processed
>
> Is this correct? If so, is there anyway I can view the traversal processing sequence in my filter when I am writing and debugging it? 

Hoping someone can shed some light on the 'traverse' directive and how I can debug my filter using different 'traverse' directives.

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/574fbf9f-c1b8-711a-f14a-3acd75cbf634%40meddatainc.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                         ` <574fbf9f-c1b8-711a-f14a-3acd75cbf634-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-05-30 19:23                                           ` H
       [not found]                                             ` <05ba5663-1578-d555-8539-d6a2bdff6743-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-05-30 19:23 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On 05/30/2023 02:30 PM, H wrote:
> On 05/29/2023 12:31 AM, H wrote:
>> On May 28, 2023 8:50:56 PM EDT, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>>
>>     On 05/26/2023 03:43 PM, H wrote:
>>>     No CSS (I had mentioned that in a previous message), also no modifications to the markdown file so the entire interpretation of layout, adding style information etc. needs to be in my custom PDF writer. This custom writer will - obviously - be specific for this single dedicated use by myself.
>>>
>>>     Any pointers (links, code fragments to look at etc.) as to how I should traverse the tree to be able to output my custom PDF would be greatly appreciated since this will be my first pandoc writer.
>>>
>>     I am making some progress working on my custom writer for my desired html output layout. I am using the 3.0 syntax where the output function looks like
>>
>>     Writer.Pandoc = function(doc)
>>         return Writer.Blocks(doc.blocks)
>>     end
>>
>>     At the start of my document I also have
>>
>>     Writer = pandoc.scaffolding.Writer
>>
>>     with customization added for inlines and blocks added.
>>
>>     In the Writer.Pandoc function above, is there a way I can see exactly in which order the document is evaluated? I am interested in exploring traverse = 'topdown' vs. traverse = 'typewise' as I think the topdown traversal will be required to add the necessary <div> and </div> in the correct locations to my final document.
>>
>>     Again, please bear in mind that I will do /all/ processing in this my custom lua writer.
>>
>>     Thanks.
>>
>>
>> Upon further reading, it looks like the traverse directive might only be applicable to filters when the AST is being processed
>>
>> Is this correct? If so, is there anyway I can view the traversal processing sequence in my filter when I am writing and debugging it? 
>
> Hoping someone can shed some light on the 'traverse' directive and how I can debug my filter using different 'traverse' directives.
>
> Thanks.
>
Upon further experimentation, it looks like outputting to 'native' format, ie the AST tree after running a filter will show me what the modified tree looks like.

It would have been nice to have some version of 'verbose' to apply to a filter to see in which order elements are processed.


-- 
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/05ba5663-1578-d555-8539-d6a2bdff6743%40meddatainc.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                             ` <05ba5663-1578-d555-8539-d6a2bdff6743-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-06-01  8:34                                               ` 'William Lupton' via pandoc-discuss
       [not found]                                                 ` <CAEe_xxhTjZJRuNZFtYMqh1eSNM9yobfgs_YTj2muxs1px0ygjg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: 'William Lupton' via pandoc-discuss @ 2023-06-01  8:34 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Am I correct in thinking that when you say "filter" here, you really mean
"writer"?

In filters, you can use the 'traverse' field to force top-down traversal.
See https://pandoc.org/lua-filters.html#traversal-order

In writers, you can choose to call doc:walk(), which will honour
'traverse'. See
https://pandoc.org/custom-writers.html#example-modified-markdown-writer
(and example below)

However, if you use pandoc.scaffolding.Writer (as I think you are?) then I
suspect that you can't control the traversal order (but I'm not sure that
it makes sense to do so, because, for example, surely you always want the
contents of a <div> to have been traversed before you add '<div>' and
'</div>'?).

With the custom writer shown below, and with an input file that consists of
the single line 'Text' (and using my logging module
<https://github.com/pandoc-ext/logging>), you get this with the default
'typewise' traversal:

(#) inline Str "Text"
(#) inlines Inlines[1] {[1] Str "Text"}
(#) block Para {content: Inlines[1] {[1] Str "Text"}}
(#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
(#) meta Meta {}
(#) doc Pandoc {
  blocks: Blocks[1] {
    [1] Para {
      content: Inlines[1] {
        [1] Str "Text"
      }
    }
  }
  meta: Meta {}
}

...and this with 'topdown' traversal:

(#) doc Pandoc {
  blocks: Blocks[1] {
    [1] Para {
      content: Inlines[1] {
        [1] Str "Text"
      }
    }
  }
  meta: Meta {}
}
(#) meta Meta {}
(#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
(#) block Para {content: Inlines[1] {[1] Str "Text"}}
(#) inlines Inlines[1] {[1] Str "Text"}
(#) inline Str "Text"

The writer:

local logging = require 'logging'

local function report(label, elem)
    logging.temp(label, elem)
end

-- 'typewise' (default) or 'topdown'
local traverse = 'topdown'

function Writer (doc, opts)
    local filter = {
        traverse = traverse,
        Inline = function(inline)
            report('inline', inline)
        end,
        Inlines= function(inlines)
            report('inlines', inlines)
        end,
        Block = function(block)
            report('block', block)
        end,
        Blocks = function(blocks)
            report('blocks', blocks)
        end,
        Meta = function(meta)
            report('meta', meta)
        end,
        Pandoc = function(doc)
            report('doc', doc)
        end,
    }
    return pandoc.write(doc:walk(filter), 'html', opts)
end

On Tue, 30 May 2023 at 20:23, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:

> On 05/30/2023 02:30 PM, H wrote:
>
> On 05/29/2023 12:31 AM, H wrote:
>
> On May 28, 2023 8:50:56 PM EDT, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
> <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>>
>> On 05/26/2023 03:43 PM, H wrote:
>>
>> No CSS (I had mentioned that in a previous message), also no
>> modifications to the markdown file so the entire interpretation of layout,
>> adding style information etc. needs to be in my custom PDF writer. This
>> custom writer will - obviously - be specific for this single dedicated use
>> by myself.
>>
>> Any pointers (links, code fragments to look at etc.) as to how I should
>> traverse the tree to be able to output my custom PDF would be greatly
>> appreciated since this will be my first pandoc writer.
>>
>> I am making some progress working on my custom writer for my desired html
>> output layout. I am using the 3.0 syntax where the output function looks
>> like
>>
>> Writer.Pandoc = function(doc)
>>     return Writer.Blocks(doc.blocks)
>> end
>>
>> At the start of my document I also have
>>
>> Writer = pandoc.scaffolding.Writer
>>
>> with customization added for inlines and blocks added.
>>
>> In the Writer.Pandoc function above, is there a way I can see exactly in
>> which order the document is evaluated? I am interested in exploring
>> traverse = 'topdown' vs. traverse = 'typewise' as I think the topdown
>> traversal will be required to add the necessary <div> and </div> in the
>> correct locations to my final document.
>>
>> Again, please bear in mind that I will do /all/ processing in this my
>> custom lua writer.
>>
>> Thanks.
>>
>
> Upon further reading, it looks like the traverse directive might only be
> applicable to filters when the AST is being processed
>
> Is this correct? If so, is there anyway I can view the traversal
> processing sequence in my filter when I am writing and debugging it?
>
> Hoping someone can shed some light on the 'traverse' directive and how I
> can debug my filter using different 'traverse' directives.
>
> Thanks.
>
> Upon further experimentation, it looks like outputting to 'native' format,
> ie the AST tree after running a filter will show me what the modified tree
> looks like.
>
> It would have been nice to have some version of 'verbose' to apply to a
> filter to see in which order elements are processed.
>
>
> --
> 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/05ba5663-1578-d555-8539-d6a2bdff6743%40meddatainc.com
> <https://groups.google.com/d/msgid/pandoc-discuss/05ba5663-1578-d555-8539-d6a2bdff6743%40meddatainc.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEe_xxhTjZJRuNZFtYMqh1eSNM9yobfgs_YTj2muxs1px0ygjg%40mail.gmail.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                                 ` <CAEe_xxhTjZJRuNZFtYMqh1eSNM9yobfgs_YTj2muxs1px0ygjg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-06-06 19:14                                                   ` H
       [not found]                                                     ` <7878b22d-bf64-2d25-1136-d9f9cf5e135b-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-06-06 19:14 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-discuss wrote:
> Am I correct in thinking that when you say "filter" here, you really mean "writer"?
>
> In filters, you can use the 'traverse' field to force top-down traversal. See https://pandoc.org/lua-filters.html#traversal-order
>
> In writers, you can choose to call doc:walk(), which will honour 'traverse'. See https://pandoc.org/custom-writers.html#example-modified-markdown-writer (and example below)
>
> However, if you use pandoc.scaffolding.Writer (as I think you are?) then I suspect that you can't control the traversal order (but I'm not sure that it makes sense to do so, because, for example, surely you always want the contents of a <div> to have been traversed before you add '<div>' and '</div>'?).
>
> With the custom writer shown below, and with an input file that consists of the single line 'Text' (and using my logging module <https://github.com/pandoc-ext/logging>), you get this with the default 'typewise' traversal:
>
> (#) inline Str "Text"
> (#) inlines Inlines[1] {[1] Str "Text"}
> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
> (#) meta Meta {}
> (#) doc Pandoc {
>   blocks: Blocks[1] {
>     [1] Para {
>       content: Inlines[1] {
>         [1] Str "Text"
>       }
>     }
>   }
>   meta: Meta {}
> }
>
> ...and this with 'topdown' traversal:
>
> (#) doc Pandoc {
>   blocks: Blocks[1] {
>     [1] Para {
>       content: Inlines[1] {
>         [1] Str "Text"
>       }
>     }
>   }
>   meta: Meta {}
> }
> (#) meta Meta {}
> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
> (#) inlines Inlines[1] {[1] Str "Text"}
> (#) inline Str "Text"
>
> The writer:
>
> local logging = require 'logging'
>
> local function report(label, elem)
>     logging.temp(label, elem)
> end
>
> -- 'typewise' (default) or 'topdown'
> local traverse = 'topdown'
>
> function Writer (doc, opts)
>     local filter = {
>         traverse = traverse,
>         Inline = function(inline)
>             report('inline', inline)
>         end,
>         Inlines= function(inlines)
>             report('inlines', inlines)
>         end,
>         Block = function(block)
>             report('block', block)
>         end,
>         Blocks = function(blocks)
>             report('blocks', blocks)
>         end,
>         Meta = function(meta)
>             report('meta', meta)
>         end,
>         Pandoc = function(doc)
>             report('doc', doc)
>         end,
>     }
>     return pandoc.write(doc:walk(filter), 'html', opts)
> end
>
> On Tue, 30 May 2023 at 20:23, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents@meddatainc.com>> wrote:
>
>     On 05/30/2023 02:30 PM, H wrote:
>>     On 05/29/2023 12:31 AM, H wrote:
>>>     On May 28, 2023 8:50:56 PM EDT, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> <mailto:agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>>>
>>>         On 05/26/2023 03:43 PM, H wrote:
>>>>         No CSS (I had mentioned that in a previous message), also no modifications to the markdown file so the entire interpretation of layout, adding style information etc. needs to be in my custom PDF writer. This custom writer will - obviously - be specific for this single dedicated use by myself.
>>>>
>>>>         Any pointers (links, code fragments to look at etc.) as to how I should traverse the tree to be able to output my custom PDF would be greatly appreciated since this will be my first pandoc writer.
>>>>
>>>         I am making some progress working on my custom writer for my desired html output layout. I am using the 3.0 syntax where the output function looks like
>>>
>>>         Writer.Pandoc = function(doc)
>>>             return Writer.Blocks(doc.blocks)
>>>         end
>>>
>>>         At the start of my document I also have
>>>
>>>         Writer = pandoc.scaffolding.Writer
>>>
>>>         with customization added for inlines and blocks added.
>>>
>>>         In the Writer.Pandoc function above, is there a way I can see exactly in which order the document is evaluated? I am interested in exploring traverse = 'topdown' vs. traverse = 'typewise' as I think the topdown traversal will be required to add the necessary <div> and </div> in the correct locations to my final document.
>>>
>>>         Again, please bear in mind that I will do /all/ processing in this my custom lua writer.
>>>
>>>         Thanks.
>>>
>>>
>>>     Upon further reading, it looks like the traverse directive might only be applicable to filters when the AST is being processed
>>>
>>>     Is this correct? If so, is there anyway I can view the traversal processing sequence in my filter when I am writing and debugging it? 
>>
>>     Hoping someone can shed some light on the 'traverse' directive and how I can debug my filter using different 'traverse' directives.
>>
>>     Thanks.
>>
>     Upon further experimentation, it looks like outputting to 'native' format, ie the AST tree after running a filter will show me what the modified tree looks like.
>
>     It would have been nice to have some version of 'verbose' to apply to a filter to see in which order elements are processed.
>
>
>     -- 
>     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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>     To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/05ba5663-1578-d555-8539-d6a2bdff6743%40meddatainc.com <https://groups.google.com/d/msgid/pandoc-discuss/05ba5663-1578-d555-8539-d6a2bdff6743%40meddatainc.com?utm_medium=email&utm_source=footer>.
>
> -- 
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxhTjZJRuNZFtYMqh1eSNM9yobfgs_YTj2muxs1px0ygjg%40mail.gmail.com <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxhTjZJRuNZFtYMqh1eSNM9yobfgs_YTj2muxs1px0ygjg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Thank you for your thoughtful response. I realize I have used the term 'filter' and 'writer' cavalierly. I have a "slightly" complicated layout I want to output from the writer and my thought right now is that I should try to add the <div> and </div> in the right places in a filter and then let the writer just output the resulting html.

I may have to traverse the AST several times in my filter to accomplish the result since multiple <div></div> need to be added at different levels to achieve the desired output.

I just downloaded your logging filter to aid in the development and am also working on formalizing the rules for adding <div></div>.


-- 
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/7878b22d-bf64-2d25-1136-d9f9cf5e135b%40meddatainc.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                                     ` <7878b22d-bf64-2d25-1136-d9f9cf5e135b-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-06-11  2:25                                                       ` H
       [not found]                                                         ` <992af9a4-285c-a20f-56de-347ea88f021f-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-06-11  2:25 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On 06/06/2023 03:14 PM, H wrote:
> On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-discuss wrote:
>> Am I correct in thinking that when you say "filter" here, you really mean "writer"?
>>
>> In filters, you can use the 'traverse' field to force top-down traversal. See https://pandoc.org/lua-filters.html#traversal-order
>>
>> In writers, you can choose to call doc:walk(), which will honour 'traverse'. See https://pandoc.org/custom-writers.html#example-modified-markdown-writer (and example below)
>>
>> However, if you use pandoc.scaffolding.Writer (as I think you are?) then I suspect that you can't control the traversal order (but I'm not sure that it makes sense to do so, because, for example, surely you always want the contents of a <div> to have been traversed before you add '<div>' and '</div>'?).
>>
>> With the custom writer shown below, and with an input file that consists of the single line 'Text' (and using my logging module <https://github.com/pandoc-ext/logging>), you get this with the default 'typewise' traversal:
>>
>> (#) inline Str "Text"
>> (#) inlines Inlines[1] {[1] Str "Text"}
>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
>> (#) meta Meta {}
>> (#) doc Pandoc {
>>   blocks: Blocks[1] {
>>     [1] Para {
>>       content: Inlines[1] {
>>         [1] Str "Text"
>>       }
>>     }
>>   }
>>   meta: Meta {}
>> }
>>
>> ...and this with 'topdown' traversal:
>>
>> (#) doc Pandoc {
>>   blocks: Blocks[1] {
>>     [1] Para {
>>       content: Inlines[1] {
>>         [1] Str "Text"
>>       }
>>     }
>>   }
>>   meta: Meta {}
>> }
>> (#) meta Meta {}
>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>> (#) inlines Inlines[1] {[1] Str "Text"}
>> (#) inline Str "Text"
>>
>> The writer:
>>
>> local logging = require 'logging'
>>
>> local function report(label, elem)
>>     logging.temp(label, elem)
>> end
>>
>> -- 'typewise' (default) or 'topdown'
>> local traverse = 'topdown'
>>
>> function Writer (doc, opts)
>>     local filter = {
>>         traverse = traverse,
>>         Inline = function(inline)
>>             report('inline', inline)
>>         end,
>>         Inlines= function(inlines)
>>             report('inlines', inlines)
>>         end,
>>         Block = function(block)
>>             report('block', block)
>>         end,
>>         Blocks = function(blocks)
>>             report('blocks', blocks)
>>         end,
>>         Meta = function(meta)
>>             report('meta', meta)
>>         end,
>>         Pandoc = function(doc)
>>             report('doc', doc)
>>         end,
>>     }
>>     return pandoc.write(doc:walk(filter), 'html', opts)
>> end
>>
> Thank you for your thoughtful response. I realize I have used the term 'filter' and 'writer' cavalierly. I have a "slightly" complicated layout I want to output from the writer and my thought right now is that I should try to add the <div> and </div> in the right places in a filter and then let the writer just output the resulting html.
>
> I may have to traverse the AST several times in my filter to accomplish the result since multiple <div></div> need to be added at different levels to achieve the desired output.
>
> I just downloaded your logging filter to aid in the development and am also working on formalizing the rules for adding <div></div>.
>
>
I spent some more time learning more about writing filters and have made some progress.

I think the entire logic for adding <div></div> to achieve the desired layout might be doable in the filter and most of it seems to be working.

One thing I found is that when an image is included using the following syntax
![test](https://www.somedomain.tld/test.jpg)
pandoc wraps the <image> element in <figure></figure> which I think I don't want/need.

How can I get rid of <figure> wrapped around <image> elements? At the very least I want got get rid of <figurecaption>some text I do not need</figurecaption> inside the <figure></figure> element?

-- 
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/992af9a4-285c-a20f-56de-347ea88f021f%40meddatainc.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                                         ` <992af9a4-285c-a20f-56de-347ea88f021f-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-06-11 13:51                                                           ` BPJ
       [not found]                                                             ` <CADAJKhDBqvOL469ZXigacDug2dMx=OiGWjteOM3fXqT-29BM5A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: BPJ @ 2023-06-11 13:51 UTC (permalink / raw)
  To: pandoc-discuss

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

An image will be wrapped in a `<figure>` when it is the only thing in a
paragraph, so the workaround is to add a non-breaking space after the image.

This filter removes the Figure leaving the Image and an nbspace in a Para
unless the Image has a class `.fig`.

It can be used both to globally insert the needed nbspace into Markdown or
used always to so to speak implement a better syntax where you clearly mark
a lone-image paragraph if you want a figure.

https://gist.github.com/bpj/6664b0b0755e7ebe9007de4d1426d400

Den sön 11 juni 2023 04:26H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> skrev:

> On 06/06/2023 03:14 PM, H wrote:
>
> On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-discuss wrote:
>
> Am I correct in thinking that when you say "filter" here, you really mean
> "writer"?
>
> In filters, you can use the 'traverse' field to force top-down traversal.
> See https://pandoc.org/lua-filters.html#traversal-order
>
> In writers, you can choose to call doc:walk(), which will honour
> 'traverse'. See
> https://pandoc.org/custom-writers.html#example-modified-markdown-writer
> (and example below)
>
> However, if you use pandoc.scaffolding.Writer (as I think you are?) then I
> suspect that you can't control the traversal order (but I'm not sure that
> it makes sense to do so, because, for example, surely you always want the
> contents of a <div> to have been traversed before you add '<div>' and
> '</div>'?).
>
> With the custom writer shown below, and with an input file that consists
> of the single line 'Text' (and using my logging module
> <https://github.com/pandoc-ext/logging>), you get this with the default
> 'typewise' traversal:
>
> (#) inline Str "Text"
> (#) inlines Inlines[1] {[1] Str "Text"}
> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
> (#) meta Meta {}
> (#) doc Pandoc {
>   blocks: Blocks[1] {
>     [1] Para {
>       content: Inlines[1] {
>         [1] Str "Text"
>       }
>     }
>   }
>   meta: Meta {}
> }
>
> ...and this with 'topdown' traversal:
>
> (#) doc Pandoc {
>   blocks: Blocks[1] {
>     [1] Para {
>       content: Inlines[1] {
>         [1] Str "Text"
>       }
>     }
>   }
>   meta: Meta {}
> }
> (#) meta Meta {}
> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
> (#) inlines Inlines[1] {[1] Str "Text"}
> (#) inline Str "Text"
>
> The writer:
>
> local logging = require 'logging'
>
> local function report(label, elem)
>     logging.temp(label, elem)
> end
>
> -- 'typewise' (default) or 'topdown'
> local traverse = 'topdown'
>
> function Writer (doc, opts)
>     local filter = {
>         traverse = traverse,
>         Inline = function(inline)
>             report('inline', inline)
>         end,
>         Inlines= function(inlines)
>             report('inlines', inlines)
>         end,
>         Block = function(block)
>             report('block', block)
>         end,
>         Blocks = function(blocks)
>             report('blocks', blocks)
>         end,
>         Meta = function(meta)
>             report('meta', meta)
>         end,
>         Pandoc = function(doc)
>             report('doc', doc)
>         end,
>     }
>     return pandoc.write(doc:walk(filter), 'html', opts)
> end
>
> Thank you for your thoughtful response. I realize I have used the term
> 'filter' and 'writer' cavalierly. I have a "slightly" complicated layout I
> want to output from the writer and my thought right now is that I should
> try to add the <div> and </div> in the right places in a filter and then
> let the writer just output the resulting html.
>
> I may have to traverse the AST several times in my filter to accomplish
> the result since multiple <div></div> need to be added at different levels
> to achieve the desired output.
>
> I just downloaded your logging filter to aid in the development and am
> also working on formalizing the rules for adding <div></div>.
>
>
> I spent some more time learning more about writing filters and have made
> some progress.
>
> I think the entire logic for adding <div></div> to achieve the desired
> layout might be doable in the filter and most of it seems to be working.
>
> One thing I found is that when an image is included using the following
> syntax
> ![test](https://www.somedomain.tld/test.jpg)
> pandoc wraps the <image> element in <figure></figure> which I think I
> don't want/need.
>
> How can I get rid of <figure> wrapped around <image> elements? At the very
> least I want got get rid of <figurecaption>some text I do not
> need</figurecaption> inside the <figure></figure> element?
>
> --
> 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/992af9a4-285c-a20f-56de-347ea88f021f%40meddatainc.com
> <https://groups.google.com/d/msgid/pandoc-discuss/992af9a4-285c-a20f-56de-347ea88f021f%40meddatainc.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CADAJKhDBqvOL469ZXigacDug2dMx%3DOiGWjteOM3fXqT-29BM5A%40mail.gmail.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                                             ` <CADAJKhDBqvOL469ZXigacDug2dMx=OiGWjteOM3fXqT-29BM5A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-06-11 15:54                                                               ` H
       [not found]                                                                 ` <b189960a-3e0d-19b8-91e2-c16dc88cd595-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-06-11 15:54 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On 06/11/2023 09:51 AM, BPJ wrote:
> An image will be wrapped in a `<figure>` when it is the only thing in a paragraph, so the workaround is to add a non-breaking space after the image.
>
> This filter removes the Figure leaving the Image and an nbspace in a Para unless the Image has a class `.fig`.
>
> It can be used both to globally insert the needed nbspace into Markdown or used always to so to speak implement a better syntax where you clearly mark a lone-image paragraph if you want a figure.
>
> https://gist.github.com/bpj/6664b0b0755e7ebe9007de4d1426d400
>
> Den sön 11 juni 2023 04:26H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents@meddatainc.com>> skrev:
>
>     On 06/06/2023 03:14 PM, H wrote:
>>     On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-discuss wrote:
>>>     Am I correct in thinking that when you say "filter" here, you really mean "writer"?
>>>
>>>     In filters, you can use the 'traverse' field to force top-down traversal. See https://pandoc.org/lua-filters.html#traversal-order
>>>
>>>     In writers, you can choose to call doc:walk(), which will honour 'traverse'. See https://pandoc.org/custom-writers.html#example-modified-markdown-writer (and example below)
>>>
>>>     However, if you use pandoc.scaffolding.Writer (as I think you are?) then I suspect that you can't control the traversal order (but I'm not sure that it makes sense to do so, because, for example, surely you always want the contents of a <div> to have been traversed before you add '<div>' and '</div>'?).
>>>
>>>     With the custom writer shown below, and with an input file that consists of the single line 'Text' (and using my logging module <https://github.com/pandoc-ext/logging>), you get this with the default 'typewise' traversal:
>>>
>>>     (#) inline Str "Text"
>>>     (#) inlines Inlines[1] {[1] Str "Text"}
>>>     (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>>>     (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
>>>     (#) meta Meta {}
>>>     (#) doc Pandoc {
>>>       blocks: Blocks[1] {
>>>         [1] Para {
>>>           content: Inlines[1] {
>>>             [1] Str "Text"
>>>           }
>>>         }
>>>       }
>>>       meta: Meta {}
>>>     }
>>>
>>>     ...and this with 'topdown' traversal:
>>>
>>>     (#) doc Pandoc {
>>>       blocks: Blocks[1] {
>>>         [1] Para {
>>>           content: Inlines[1] {
>>>             [1] Str "Text"
>>>           }
>>>         }
>>>       }
>>>       meta: Meta {}
>>>     }
>>>     (#) meta Meta {}
>>>     (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
>>>     (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>>>     (#) inlines Inlines[1] {[1] Str "Text"}
>>>     (#) inline Str "Text"
>>>
>>>     The writer:
>>>
>>>     local logging = require 'logging'
>>>
>>>     local function report(label, elem)
>>>         logging.temp(label, elem)
>>>     end
>>>
>>>     -- 'typewise' (default) or 'topdown'
>>>     local traverse = 'topdown'
>>>
>>>     function Writer (doc, opts)
>>>         local filter = {
>>>             traverse = traverse,
>>>             Inline = function(inline)
>>>                 report('inline', inline)
>>>             end,
>>>             Inlines= function(inlines)
>>>                 report('inlines', inlines)
>>>             end,
>>>             Block = function(block)
>>>                 report('block', block)
>>>             end,
>>>             Blocks = function(blocks)
>>>                 report('blocks', blocks)
>>>             end,
>>>             Meta = function(meta)
>>>                 report('meta', meta)
>>>             end,
>>>             Pandoc = function(doc)
>>>                 report('doc', doc)
>>>             end,
>>>         }
>>>         return pandoc.write(doc:walk(filter), 'html', opts)
>>>     end
>>>
>>     Thank you for your thoughtful response. I realize I have used the term 'filter' and 'writer' cavalierly. I have a "slightly" complicated layout I want to output from the writer and my thought right now is that I should try to add the <div> and </div> in the right places in a filter and then let the writer just output the resulting html.
>>
>>     I may have to traverse the AST several times in my filter to accomplish the result since multiple <div></div> need to be added at different levels to achieve the desired output.
>>
>>     I just downloaded your logging filter to aid in the development and am also working on formalizing the rules for adding <div></div>.
>>
>>
>     I spent some more time learning more about writing filters and have made some progress.
>
>     I think the entire logic for adding <div></div> to achieve the desired layout might be doable in the filter and most of it seems to be working.
>
>     One thing I found is that when an image is included using the following syntax
>     ![test](https://www.somedomain.tld/test.jpg)
>     pandoc wraps the <image> element in <figure></figure> which I think I don't want/need.
>
>     How can I get rid of <figure> wrapped around <image> elements? At the very least I want got get rid of <figurecaption>some text I do not need</figurecaption> inside the <figure></figure> element?
>
Got it, thank you and I will look at your code. If I am not adding the non-breakable space after the image however, how do I get rid of the <figurecaption> element which I do not need (or want cluttering up my code)?

-- 
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/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                                                 ` <b189960a-3e0d-19b8-91e2-c16dc88cd595-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-06-12 21:09                                                                   ` 'William Lupton' via pandoc-discuss
       [not found]                                                                     ` <CAEe_xxjer3B9Qy8oGGNx_ARySSMD1mG8-AD6-EJQQXYnddFMYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: 'William Lupton' via pandoc-discuss @ 2023-06-12 21:09 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

I'm not sure whether this helps in your situation, but if the image has no
alt text then there'll be no caption in the HTML (and no figure element
either). This document:

![test](https://www.somedomain.tld/test.jpg)

![](https://www.somedomain.tld/test.jpg)

...gives this HTML:

<figure>
<img src="https://www.somedomain.tld/test.jpg" alt="test" />
<figcaption aria-hidden="true">test</figcaption>
</figure>
<p><img src="https://www.somedomain.tld/test.jpg" /></p>

See https://pandoc.org/MANUAL.html#extension-implicit_figures


On Sun, 11 Jun 2023 at 16:54, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:

> On 06/11/2023 09:51 AM, BPJ wrote:
>
> An image will be wrapped in a `<figure>` when it is the only thing in a
> paragraph, so the workaround is to add a non-breaking space after the
> image.
>
> This filter removes the Figure leaving the Image and an nbspace in a Para
> unless the Image has a class `.fig`.
>
> It can be used both to globally insert the needed nbspace into Markdown or
> used always to so to speak implement a better syntax where you clearly mark
> a lone-image paragraph if you want a figure.
>
> https://gist.github.com/bpj/6664b0b0755e7ebe9007de4d1426d400
>
> Den sön 11 juni 2023 04:26H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> skrev:
>
>> On 06/06/2023 03:14 PM, H wrote:
>>
>> On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-discuss wrote:
>>
>> Am I correct in thinking that when you say "filter" here, you really mean
>> "writer"?
>>
>> In filters, you can use the 'traverse' field to force top-down traversal.
>> See https://pandoc.org/lua-filters.html#traversal-order
>>
>> In writers, you can choose to call doc:walk(), which will honour
>> 'traverse'. See
>> https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>> (and example below)
>>
>> However, if you use pandoc.scaffolding.Writer (as I think you are?) then
>> I suspect that you can't control the traversal order (but I'm not sure that
>> it makes sense to do so, because, for example, surely you always want the
>> contents of a <div> to have been traversed before you add '<div>' and
>> '</div>'?).
>>
>> With the custom writer shown below, and with an input file that consists
>> of the single line 'Text' (and using my logging module
>> <https://github.com/pandoc-ext/logging>), you get this with the default
>> 'typewise' traversal:
>>
>> (#) inline Str "Text"
>> (#) inlines Inlines[1] {[1] Str "Text"}
>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
>> (#) meta Meta {}
>> (#) doc Pandoc {
>>   blocks: Blocks[1] {
>>     [1] Para {
>>       content: Inlines[1] {
>>         [1] Str "Text"
>>       }
>>     }
>>   }
>>   meta: Meta {}
>> }
>>
>> ...and this with 'topdown' traversal:
>>
>> (#) doc Pandoc {
>>   blocks: Blocks[1] {
>>     [1] Para {
>>       content: Inlines[1] {
>>         [1] Str "Text"
>>       }
>>     }
>>   }
>>   meta: Meta {}
>> }
>> (#) meta Meta {}
>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str "Text"}}}
>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>> (#) inlines Inlines[1] {[1] Str "Text"}
>> (#) inline Str "Text"
>>
>> The writer:
>>
>> local logging = require 'logging'
>>
>> local function report(label, elem)
>>     logging.temp(label, elem)
>> end
>>
>> -- 'typewise' (default) or 'topdown'
>> local traverse = 'topdown'
>>
>> function Writer (doc, opts)
>>     local filter = {
>>         traverse = traverse,
>>         Inline = function(inline)
>>             report('inline', inline)
>>         end,
>>         Inlines= function(inlines)
>>             report('inlines', inlines)
>>         end,
>>         Block = function(block)
>>             report('block', block)
>>         end,
>>         Blocks = function(blocks)
>>             report('blocks', blocks)
>>         end,
>>         Meta = function(meta)
>>             report('meta', meta)
>>         end,
>>         Pandoc = function(doc)
>>             report('doc', doc)
>>         end,
>>     }
>>     return pandoc.write(doc:walk(filter), 'html', opts)
>> end
>>
>> Thank you for your thoughtful response. I realize I have used the term
>> 'filter' and 'writer' cavalierly. I have a "slightly" complicated layout I
>> want to output from the writer and my thought right now is that I should
>> try to add the <div> and </div> in the right places in a filter and then
>> let the writer just output the resulting html.
>>
>> I may have to traverse the AST several times in my filter to accomplish
>> the result since multiple <div></div> need to be added at different levels
>> to achieve the desired output.
>>
>> I just downloaded your logging filter to aid in the development and am
>> also working on formalizing the rules for adding <div></div>.
>>
>>
>> I spent some more time learning more about writing filters and have made
>> some progress.
>>
>> I think the entire logic for adding <div></div> to achieve the desired
>> layout might be doable in the filter and most of it seems to be working.
>>
>> One thing I found is that when an image is included using the following
>> syntax
>> ![test](https://www.somedomain.tld/test.jpg)
>> pandoc wraps the <image> element in <figure></figure> which I think I
>> don't want/need.
>>
>> How can I get rid of <figure> wrapped around <image> elements? At the
>> very least I want got get rid of <figurecaption>some text I do not
>> need</figurecaption> inside the <figure></figure> element?
>>
>> Got it, thank you and I will look at your code. If I am not adding the
> non-breakable space after the image however, how do I get rid of the
> <figurecaption> element which I do not need (or want cluttering up my code)?
>
> --
> 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/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com
> <https://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEe_xxjer3B9Qy8oGGNx_ARySSMD1mG8-AD6-EJQQXYnddFMYA%40mail.gmail.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                                                     ` <CAEe_xxjer3B9Qy8oGGNx_ARySSMD1mG8-AD6-EJQQXYnddFMYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-06-12 21:18                                                                       ` H
       [not found]                                                                         ` <EAF5063B-4655-48B3-8961-AF664AE3C94F-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: H @ 2023-06-12 21:18 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On June 12, 2023 5:09:20 PM EDT, 'William Lupton' via pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote:
>I'm not sure whether this helps in your situation, but if the image has
>no
>alt text then there'll be no caption in the HTML (and no figure element
>either). This document:
>
>![test](https://www.somedomain.tld/test.jpg)
>
>![](https://www.somedomain.tld/test.jpg)
>
>...gives this HTML:
>
><figure>
><img src="https://www.somedomain.tld/test.jpg" alt="test" />
><figcaption aria-hidden="true">test</figcaption>
></figure>
><p><img src="https://www.somedomain.tld/test.jpg" /></p>
>
>See https://pandoc.org/MANUAL.html#extension-implicit_figures
>
>
>On Sun, 11 Jun 2023 at 16:54, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>
>> On 06/11/2023 09:51 AM, BPJ wrote:
>>
>> An image will be wrapped in a `<figure>` when it is the only thing in
>a
>> paragraph, so the workaround is to add a non-breaking space after the
>> image.
>>
>> This filter removes the Figure leaving the Image and an nbspace in a
>Para
>> unless the Image has a class `.fig`.
>>
>> It can be used both to globally insert the needed nbspace into
>Markdown or
>> used always to so to speak implement a better syntax where you
>clearly mark
>> a lone-image paragraph if you want a figure.
>>
>> https://gist.github.com/bpj/6664b0b0755e7ebe9007de4d1426d400
>>
>> Den sön 11 juni 2023 04:26H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> skrev:
>>
>>> On 06/06/2023 03:14 PM, H wrote:
>>>
>>> On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-discuss wrote:
>>>
>>> Am I correct in thinking that when you say "filter" here, you really
>mean
>>> "writer"?
>>>
>>> In filters, you can use the 'traverse' field to force top-down
>traversal.
>>> See https://pandoc.org/lua-filters.html#traversal-order
>>>
>>> In writers, you can choose to call doc:walk(), which will honour
>>> 'traverse'. See
>>>
>https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>>> (and example below)
>>>
>>> However, if you use pandoc.scaffolding.Writer (as I think you are?)
>then
>>> I suspect that you can't control the traversal order (but I'm not
>sure that
>>> it makes sense to do so, because, for example, surely you always
>want the
>>> contents of a <div> to have been traversed before you add '<div>'
>and
>>> '</div>'?).
>>>
>>> With the custom writer shown below, and with an input file that
>consists
>>> of the single line 'Text' (and using my logging module
>>> <https://github.com/pandoc-ext/logging>), you get this with the
>default
>>> 'typewise' traversal:
>>>
>>> (#) inline Str "Text"
>>> (#) inlines Inlines[1] {[1] Str "Text"}
>>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str
>"Text"}}}
>>> (#) meta Meta {}
>>> (#) doc Pandoc {
>>>   blocks: Blocks[1] {
>>>     [1] Para {
>>>       content: Inlines[1] {
>>>         [1] Str "Text"
>>>       }
>>>     }
>>>   }
>>>   meta: Meta {}
>>> }
>>>
>>> ...and this with 'topdown' traversal:
>>>
>>> (#) doc Pandoc {
>>>   blocks: Blocks[1] {
>>>     [1] Para {
>>>       content: Inlines[1] {
>>>         [1] Str "Text"
>>>       }
>>>     }
>>>   }
>>>   meta: Meta {}
>>> }
>>> (#) meta Meta {}
>>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str
>"Text"}}}
>>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>>> (#) inlines Inlines[1] {[1] Str "Text"}
>>> (#) inline Str "Text"
>>>
>>> The writer:
>>>
>>> local logging = require 'logging'
>>>
>>> local function report(label, elem)
>>>     logging.temp(label, elem)
>>> end
>>>
>>> -- 'typewise' (default) or 'topdown'
>>> local traverse = 'topdown'
>>>
>>> function Writer (doc, opts)
>>>     local filter = {
>>>         traverse = traverse,
>>>         Inline = function(inline)
>>>             report('inline', inline)
>>>         end,
>>>         Inlines= function(inlines)
>>>             report('inlines', inlines)
>>>         end,
>>>         Block = function(block)
>>>             report('block', block)
>>>         end,
>>>         Blocks = function(blocks)
>>>             report('blocks', blocks)
>>>         end,
>>>         Meta = function(meta)
>>>             report('meta', meta)
>>>         end,
>>>         Pandoc = function(doc)
>>>             report('doc', doc)
>>>         end,
>>>     }
>>>     return pandoc.write(doc:walk(filter), 'html', opts)
>>> end
>>>
>>> Thank you for your thoughtful response. I realize I have used the
>term
>>> 'filter' and 'writer' cavalierly. I have a "slightly" complicated
>layout I
>>> want to output from the writer and my thought right now is that I
>should
>>> try to add the <div> and </div> in the right places in a filter and
>then
>>> let the writer just output the resulting html.
>>>
>>> I may have to traverse the AST several times in my filter to
>accomplish
>>> the result since multiple <div></div> need to be added at different
>levels
>>> to achieve the desired output.
>>>
>>> I just downloaded your logging filter to aid in the development and
>am
>>> also working on formalizing the rules for adding <div></div>.
>>>
>>>
>>> I spent some more time learning more about writing filters and have
>made
>>> some progress.
>>>
>>> I think the entire logic for adding <div></div> to achieve the
>desired
>>> layout might be doable in the filter and most of it seems to be
>working.
>>>
>>> One thing I found is that when an image is included using the
>following
>>> syntax
>>> ![test](https://www.somedomain.tld/test.jpg)
>>> pandoc wraps the <image> element in <figure></figure> which I think
>I
>>> don't want/need.
>>>
>>> How can I get rid of <figure> wrapped around <image> elements? At
>the
>>> very least I want got get rid of <figurecaption>some text I do not
>>> need</figurecaption> inside the <figure></figure> element?
>>>
>>> Got it, thank you and I will look at your code. If I am not adding
>the
>> non-breakable space after the image however, how do I get rid of the
>> <figurecaption> element which I do not need (or want cluttering up my
>code)?
>>
>> --
>> 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/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com
>>
><https://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com?utm_medium=email&utm_source=footer>
>> .
>>

It does have alt text and I do want to keep that. I do, however, want to get rid of the <figurecaption> text - is this doable?

-- 
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/EAF5063B-4655-48B3-8961-AF664AE3C94F%40meddatainc.com.


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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                                                         ` <EAF5063B-4655-48B3-8961-AF664AE3C94F-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
@ 2023-06-13  8:28                                                                           ` 'William Lupton' via pandoc-discuss
       [not found]                                                                             ` <CAEe_xxjdOUK-tpNsw65u_v_gNr0nUkF5vfrQc0RQyLhJyjtHSA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 22+ messages in thread
From: 'William Lupton' via pandoc-discuss @ 2023-06-13  8:28 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

This lua filter will remove the caption:

function Figure(figure)
    figure.caption = {}
    return figure
end

(It didn't work to set figure.caption to nil. This seemed to have no
effect. Perhaps someone can explain why?)

On Mon, 12 Jun 2023 at 22:19, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:

> On June 12, 2023 5:09:20 PM EDT, 'William Lupton' via pandoc-discuss <
> pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote:
> >I'm not sure whether this helps in your situation, but if the image has
> >no
> >alt text then there'll be no caption in the HTML (and no figure element
> >either). This document:
> >
> >![test](https://www.somedomain.tld/test.jpg)
> >
> >![](https://www.somedomain.tld/test.jpg)
> >
> >...gives this HTML:
> >
> ><figure>
> ><img src="https://www.somedomain.tld/test.jpg" alt="test" />
> ><figcaption aria-hidden="true">test</figcaption>
> ></figure>
> ><p><img src="https://www.somedomain.tld/test.jpg" /></p>
> >
> >See https://pandoc.org/MANUAL.html#extension-implicit_figures
> >
> >
> >On Sun, 11 Jun 2023 at 16:54, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
> >
> >> On 06/11/2023 09:51 AM, BPJ wrote:
> >>
> >> An image will be wrapped in a `<figure>` when it is the only thing in
> >a
> >> paragraph, so the workaround is to add a non-breaking space after the
> >> image.
> >>
> >> This filter removes the Figure leaving the Image and an nbspace in a
> >Para
> >> unless the Image has a class `.fig`.
> >>
> >> It can be used both to globally insert the needed nbspace into
> >Markdown or
> >> used always to so to speak implement a better syntax where you
> >clearly mark
> >> a lone-image paragraph if you want a figure.
> >>
> >> https://gist.github.com/bpj/6664b0b0755e7ebe9007de4d1426d400
> >>
> >> Den sön 11 juni 2023 04:26H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> skrev:
> >>
> >>> On 06/06/2023 03:14 PM, H wrote:
> >>>
> >>> On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-discuss wrote:
> >>>
> >>> Am I correct in thinking that when you say "filter" here, you really
> >mean
> >>> "writer"?
> >>>
> >>> In filters, you can use the 'traverse' field to force top-down
> >traversal.
> >>> See https://pandoc.org/lua-filters.html#traversal-order
> >>>
> >>> In writers, you can choose to call doc:walk(), which will honour
> >>> 'traverse'. See
> >>>
> >https://pandoc.org/custom-writers.html#example-modified-markdown-writer
> >>> (and example below)
> >>>
> >>> However, if you use pandoc.scaffolding.Writer (as I think you are?)
> >then
> >>> I suspect that you can't control the traversal order (but I'm not
> >sure that
> >>> it makes sense to do so, because, for example, surely you always
> >want the
> >>> contents of a <div> to have been traversed before you add '<div>'
> >and
> >>> '</div>'?).
> >>>
> >>> With the custom writer shown below, and with an input file that
> >consists
> >>> of the single line 'Text' (and using my logging module
> >>> <https://github.com/pandoc-ext/logging>), you get this with the
> >default
> >>> 'typewise' traversal:
> >>>
> >>> (#) inline Str "Text"
> >>> (#) inlines Inlines[1] {[1] Str "Text"}
> >>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
> >>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str
> >"Text"}}}
> >>> (#) meta Meta {}
> >>> (#) doc Pandoc {
> >>>   blocks: Blocks[1] {
> >>>     [1] Para {
> >>>       content: Inlines[1] {
> >>>         [1] Str "Text"
> >>>       }
> >>>     }
> >>>   }
> >>>   meta: Meta {}
> >>> }
> >>>
> >>> ...and this with 'topdown' traversal:
> >>>
> >>> (#) doc Pandoc {
> >>>   blocks: Blocks[1] {
> >>>     [1] Para {
> >>>       content: Inlines[1] {
> >>>         [1] Str "Text"
> >>>       }
> >>>     }
> >>>   }
> >>>   meta: Meta {}
> >>> }
> >>> (#) meta Meta {}
> >>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str
> >"Text"}}}
> >>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
> >>> (#) inlines Inlines[1] {[1] Str "Text"}
> >>> (#) inline Str "Text"
> >>>
> >>> The writer:
> >>>
> >>> local logging = require 'logging'
> >>>
> >>> local function report(label, elem)
> >>>     logging.temp(label, elem)
> >>> end
> >>>
> >>> -- 'typewise' (default) or 'topdown'
> >>> local traverse = 'topdown'
> >>>
> >>> function Writer (doc, opts)
> >>>     local filter = {
> >>>         traverse = traverse,
> >>>         Inline = function(inline)
> >>>             report('inline', inline)
> >>>         end,
> >>>         Inlines= function(inlines)
> >>>             report('inlines', inlines)
> >>>         end,
> >>>         Block = function(block)
> >>>             report('block', block)
> >>>         end,
> >>>         Blocks = function(blocks)
> >>>             report('blocks', blocks)
> >>>         end,
> >>>         Meta = function(meta)
> >>>             report('meta', meta)
> >>>         end,
> >>>         Pandoc = function(doc)
> >>>             report('doc', doc)
> >>>         end,
> >>>     }
> >>>     return pandoc.write(doc:walk(filter), 'html', opts)
> >>> end
> >>>
> >>> Thank you for your thoughtful response. I realize I have used the
> >term
> >>> 'filter' and 'writer' cavalierly. I have a "slightly" complicated
> >layout I
> >>> want to output from the writer and my thought right now is that I
> >should
> >>> try to add the <div> and </div> in the right places in a filter and
> >then
> >>> let the writer just output the resulting html.
> >>>
> >>> I may have to traverse the AST several times in my filter to
> >accomplish
> >>> the result since multiple <div></div> need to be added at different
> >levels
> >>> to achieve the desired output.
> >>>
> >>> I just downloaded your logging filter to aid in the development and
> >am
> >>> also working on formalizing the rules for adding <div></div>.
> >>>
> >>>
> >>> I spent some more time learning more about writing filters and have
> >made
> >>> some progress.
> >>>
> >>> I think the entire logic for adding <div></div> to achieve the
> >desired
> >>> layout might be doable in the filter and most of it seems to be
> >working.
> >>>
> >>> One thing I found is that when an image is included using the
> >following
> >>> syntax
> >>> ![test](https://www.somedomain.tld/test.jpg)
> >>> pandoc wraps the <image> element in <figure></figure> which I think
> >I
> >>> don't want/need.
> >>>
> >>> How can I get rid of <figure> wrapped around <image> elements? At
> >the
> >>> very least I want got get rid of <figurecaption>some text I do not
> >>> need</figurecaption> inside the <figure></figure> element?
> >>>
> >>> Got it, thank you and I will look at your code. If I am not adding
> >the
> >> non-breakable space after the image however, how do I get rid of the
> >> <figurecaption> element which I do not need (or want cluttering up my
> >code)?
> >>
> >> --
> >> 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/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com
> >>
> ><
> https://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com?utm_medium=email&utm_source=footer
> >
> >> .
> >>
>
> It does have alt text and I do want to keep that. I do, however, want to
> get rid of the <figurecaption> text - is this doable?
>
> --
> 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/EAF5063B-4655-48B3-8961-AF664AE3C94F%40meddatainc.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/CAEe_xxjdOUK-tpNsw65u_v_gNr0nUkF5vfrQc0RQyLhJyjtHSA%40mail.gmail.com.

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

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

* Re: Wrapping sections of text with <div></div> in custom filter
       [not found]                                                                             ` <CAEe_xxjdOUK-tpNsw65u_v_gNr0nUkF5vfrQc0RQyLhJyjtHSA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-06-13 17:28                                                                               ` H
  0 siblings, 0 replies; 22+ messages in thread
From: H @ 2023-06-13 17:28 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

On 06/13/2023 04:28 AM, 'William Lupton' via pandoc-discuss wrote:
> This lua filter will remove the caption:
>
> function Figure(figure)
>     figure.caption = {}
>     return figure
> end
>
> (It didn't work to set figure.caption to nil. This seemed to have no effect. Perhaps someone can explain why?)
>
> On Mon, 12 Jun 2023 at 22:19, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents@meddatainc.com>> wrote:
>
>     On June 12, 2023 5:09:20 PM EDT, 'William Lupton' via pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>> wrote:
>     >I'm not sure whether this helps in your situation, but if the image has
>     >no
>     >alt text then there'll be no caption in the HTML (and no figure element
>     >either). This document:
>     >
>     >![test](https://www.somedomain.tld/test.jpg)
>     >
>     >![](https://www.somedomain.tld/test.jpg)
>     >
>     >...gives this HTML:
>     >
>     ><figure>
>     ><img src="https://www.somedomain.tld/test.jpg" alt="test" />
>     ><figcaption aria-hidden="true">test</figcaption>
>     ></figure>
>     ><p><img src="https://www.somedomain.tld/test.jpg" /></p>
>     >
>     >See https://pandoc.org/MANUAL.html#extension-implicit_figures
>     >
>     >
>     >On Sun, 11 Jun 2023 at 16:54, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents@meddatainc.com>> wrote:
>     >
>     >> On 06/11/2023 09:51 AM, BPJ wrote:
>     >>
>     >> An image will be wrapped in a `<figure>` when it is the only thing in
>     >a
>     >> paragraph, so the workaround is to add a non-breaking space after the
>     >> image.
>     >>
>     >> This filter removes the Figure leaving the Image and an nbspace in a
>     >Para
>     >> unless the Image has a class `.fig`.
>     >>
>     >> It can be used both to globally insert the needed nbspace into
>     >Markdown or
>     >> used always to so to speak implement a better syntax where you
>     >clearly mark
>     >> a lone-image paragraph if you want a figure.
>     >>
>     >> https://gist.github.com/bpj/6664b0b0755e7ebe9007de4d1426d400
>     >>
>     >> Den sön 11 juni 2023 04:26H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org <mailto:agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org>> skrev:
>     >>
>     >>> On 06/06/2023 03:14 PM, H wrote:
>     >>>
>     >>> On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-discuss wrote:
>     >>>
>     >>> Am I correct in thinking that when you say "filter" here, you really
>     >mean
>     >>> "writer"?
>     >>>
>     >>> In filters, you can use the 'traverse' field to force top-down
>     >traversal.
>     >>> See https://pandoc.org/lua-filters.html#traversal-order
>     >>>
>     >>> In writers, you can choose to call doc:walk(), which will honour
>     >>> 'traverse'. See
>     >>>
>     >https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>     >>> (and example below)
>     >>>
>     >>> However, if you use pandoc.scaffolding.Writer (as I think you are?)
>     >then
>     >>> I suspect that you can't control the traversal order (but I'm not
>     >sure that
>     >>> it makes sense to do so, because, for example, surely you always
>     >want the
>     >>> contents of a <div> to have been traversed before you add '<div>'
>     >and
>     >>> '</div>'?).
>     >>>
>     >>> With the custom writer shown below, and with an input file that
>     >consists
>     >>> of the single line 'Text' (and using my logging module
>     >>> <https://github.com/pandoc-ext/logging>), you get this with the
>     >default
>     >>> 'typewise' traversal:
>     >>>
>     >>> (#) inline Str "Text"
>     >>> (#) inlines Inlines[1] {[1] Str "Text"}
>     >>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>     >>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str
>     >"Text"}}}
>     >>> (#) meta Meta {}
>     >>> (#) doc Pandoc {
>     >>>   blocks: Blocks[1] {
>     >>>     [1] Para {
>     >>>       content: Inlines[1] {
>     >>>         [1] Str "Text"
>     >>>       }
>     >>>     }
>     >>>   }
>     >>>   meta: Meta {}
>     >>> }
>     >>>
>     >>> ...and this with 'topdown' traversal:
>     >>>
>     >>> (#) doc Pandoc {
>     >>>   blocks: Blocks[1] {
>     >>>     [1] Para {
>     >>>       content: Inlines[1] {
>     >>>         [1] Str "Text"
>     >>>       }
>     >>>     }
>     >>>   }
>     >>>   meta: Meta {}
>     >>> }
>     >>> (#) meta Meta {}
>     >>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str
>     >"Text"}}}
>     >>> (#) block Para {content: Inlines[1] {[1] Str "Text"}}
>     >>> (#) inlines Inlines[1] {[1] Str "Text"}
>     >>> (#) inline Str "Text"
>     >>>
>     >>> The writer:
>     >>>
>     >>> local logging = require 'logging'
>     >>>
>     >>> local function report(label, elem)
>     >>>     logging.temp(label, elem)
>     >>> end
>     >>>
>     >>> -- 'typewise' (default) or 'topdown'
>     >>> local traverse = 'topdown'
>     >>>
>     >>> function Writer (doc, opts)
>     >>>     local filter = {
>     >>>         traverse = traverse,
>     >>>         Inline = function(inline)
>     >>>             report('inline', inline)
>     >>>         end,
>     >>>         Inlines= function(inlines)
>     >>>             report('inlines', inlines)
>     >>>         end,
>     >>>         Block = function(block)
>     >>>             report('block', block)
>     >>>         end,
>     >>>         Blocks = function(blocks)
>     >>>             report('blocks', blocks)
>     >>>         end,
>     >>>         Meta = function(meta)
>     >>>             report('meta', meta)
>     >>>         end,
>     >>>         Pandoc = function(doc)
>     >>>             report('doc', doc)
>     >>>         end,
>     >>>     }
>     >>>     return pandoc.write(doc:walk(filter), 'html', opts)
>     >>> end
>     >>>
>     >>> Thank you for your thoughtful response. I realize I have used the
>     >term
>     >>> 'filter' and 'writer' cavalierly. I have a "slightly" complicated
>     >layout I
>     >>> want to output from the writer and my thought right now is that I
>     >should
>     >>> try to add the <div> and </div> in the right places in a filter and
>     >then
>     >>> let the writer just output the resulting html.
>     >>>
>     >>> I may have to traverse the AST several times in my filter to
>     >accomplish
>     >>> the result since multiple <div></div> need to be added at different
>     >levels
>     >>> to achieve the desired output.
>     >>>
>     >>> I just downloaded your logging filter to aid in the development and
>     >am
>     >>> also working on formalizing the rules for adding <div></div>.
>     >>>
>     >>>
>     >>> I spent some more time learning more about writing filters and have
>     >made
>     >>> some progress.
>     >>>
>     >>> I think the entire logic for adding <div></div> to achieve the
>     >desired
>     >>> layout might be doable in the filter and most of it seems to be
>     >working.
>     >>>
>     >>> One thing I found is that when an image is included using the
>     >following
>     >>> syntax
>     >>> ![test](https://www.somedomain.tld/test.jpg)
>     >>> pandoc wraps the <image> element in <figure></figure> which I think
>     >I
>     >>> don't want/need.
>     >>>
>     >>> How can I get rid of <figure> wrapped around <image> elements? At
>     >the
>     >>> very least I want got get rid of <figurecaption>some text I do not
>     >>> need</figurecaption> inside the <figure></figure> element?
>     >>>
>     >>> Got it, thank you and I will look at your code. If I am not adding
>     >the
>     >> non-breakable space after the image however, how do I get rid of the
>     >> <figurecaption> element which I do not need (or want cluttering up my
>     >code)?
>     >>
>     >> --
>     >> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>     >> To view this discussion on the web visit
>     >>
>     >https://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com
>     >>
>     ><https://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com?utm_medium=email&utm_source=footer>
>     >> .
>     >>
>
>     It does have alt text and I do want to keep that. I do, however, want to get rid of the <figurecaption> text - is this doable?
>
Thank you.

-- 
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/c11494eb-470f-e0bd-7d93-be6b4f75db7d%40meddatainc.com.

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

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

end of thread, other threads:[~2023-06-13 17:28 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24 20:51 Wrapping sections of text with <div></div> in custom filter H
     [not found] ` <2fc450a6-5a16-316c-02c8-8ef055bccd11-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-05-24 23:20   ` H
     [not found]     ` <93e5b610-66a2-6ac7-1d53-8a04a8314249-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-05-25 10:42       ` Felix SOEDJEDE
     [not found]         ` <853c402b-d9ee-4c9d-8bae-15b20faf7194n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-05-25 19:36           ` H
     [not found]             ` <1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-05-25 20:38               ` 'William Lupton' via pandoc-discuss
     [not found]                 ` <CAEe_xxgNr8O73TNGgV5y=gwiLAKB3WFuX5a49Vv_RJDtojVcSQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-05-26  0:31                   ` H
     [not found]                     ` <6d414734-e661-ae2d-68a1-4dfc9cb4f035-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-05-26  6:33                       ` 'William Lupton' via pandoc-discuss
     [not found]                         ` <CAEe_xxg9ExgK4WCNz6G=r=s4DSCs4CBPERcUV431yov2UmeO8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-05-26 19:43                           ` H
     [not found]                             ` <cee5298a-37c9-6e17-6370-eecda5d9d6fb-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-05-26 21:01                               ` 'William Lupton' via pandoc-discuss
2023-05-29  0:50                               ` H
     [not found]                                 ` <4c58dad0-bd86-608e-2d68-74bd6f2f808b-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-05-29  4:31                                   ` H
     [not found]                                     ` <F41D20AD-EDDD-4AF4-A9AD-AAB8581086BF-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-05-30 18:30                                       ` H
     [not found]                                         ` <574fbf9f-c1b8-711a-f14a-3acd75cbf634-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-05-30 19:23                                           ` H
     [not found]                                             ` <05ba5663-1578-d555-8539-d6a2bdff6743-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-06-01  8:34                                               ` 'William Lupton' via pandoc-discuss
     [not found]                                                 ` <CAEe_xxhTjZJRuNZFtYMqh1eSNM9yobfgs_YTj2muxs1px0ygjg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-06-06 19:14                                                   ` H
     [not found]                                                     ` <7878b22d-bf64-2d25-1136-d9f9cf5e135b-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-06-11  2:25                                                       ` H
     [not found]                                                         ` <992af9a4-285c-a20f-56de-347ea88f021f-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-06-11 13:51                                                           ` BPJ
     [not found]                                                             ` <CADAJKhDBqvOL469ZXigacDug2dMx=OiGWjteOM3fXqT-29BM5A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-06-11 15:54                                                               ` H
     [not found]                                                                 ` <b189960a-3e0d-19b8-91e2-c16dc88cd595-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-06-12 21:09                                                                   ` 'William Lupton' via pandoc-discuss
     [not found]                                                                     ` <CAEe_xxjer3B9Qy8oGGNx_ARySSMD1mG8-AD6-EJQQXYnddFMYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-06-12 21:18                                                                       ` H
     [not found]                                                                         ` <EAF5063B-4655-48B3-8961-AF664AE3C94F-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-06-13  8:28                                                                           ` 'William Lupton' via pandoc-discuss
     [not found]                                                                             ` <CAEe_xxjdOUK-tpNsw65u_v_gNr0nUkF5vfrQc0RQyLhJyjtHSA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-06-13 17:28                                                                               ` H

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