public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Pandoc Python filter + Table constructor
@ 2017-11-04 15:34 Nizamudheen Ahmed
       [not found] ` <1be02d85-bd95-4709-82f8-f6a5460930c6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Nizamudheen Ahmed @ 2017-11-04 15:34 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi folks,

I am new to Pandoc. I am trying to write a filter using Python. I wanted to 
create and return a "Table" as part of the filter function. I understood 
that the Table constructor takes 5 arguments. But the details of them (at 
least from the Python parlance) are not available. 

My novice code to construct the Table looked like the following

            tab_le = Table ([Str("This is the title of the table")], # 
Table caption?
                            ["left", "left"], # Alignment?
                            [0.5, 0.5], # Relative width of the columns?
                            [Str("C1"), Str("C2")], #Column Header name?
                            [   # Table rows?
                               [Str("A1"), Str("B1")], 
                               [Str("A2"), Str("B2")], 
                               [Str("A3"), Str("B3")]

                            ] );

 With that code, i get the following error

>>>>
Error in $[373][0]: expected Object, encountered String
<<<<<

I am sure i am grossly off in the constructor. Can someone help me to 
create Table?


Thanks and with best regards,
Nizam



-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/1be02d85-bd95-4709-82f8-f6a5460930c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Pandoc Python filter + Table constructor
       [not found] ` <1be02d85-bd95-4709-82f8-f6a5460930c6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2017-11-04 19:34   ` Kolen Cheung
  2017-11-04 23:05   ` John MacFarlane
  1 sibling, 0 replies; 8+ messages in thread
From: Kolen Cheung @ 2017-11-04 19:34 UTC (permalink / raw)
  To: pandoc-discuss

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

Not directly answering your question, but you might consider using panflute and take a look at pantable. What do you want the filter to accomplish?

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

* Re: Pandoc Python filter + Table constructor
       [not found] ` <1be02d85-bd95-4709-82f8-f6a5460930c6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2017-11-04 19:34   ` Kolen Cheung
@ 2017-11-04 23:05   ` John MacFarlane
       [not found]     ` <20171104230532.GC97257-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2017-11-04 23:05 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

If you're using the pandocfilters library, I suggest you
check out the alternative library panflute, which is more
pythonic and easier to use.

+++ Nizamudheen Ahmed [Nov 04 17 08:34 ]:
>   Hi folks,
>   I am new to Pandoc. I am trying to write a filter using Python. I
>   wanted to create and return a "Table" as part of the filter function. I
>   understood that the Table constructor takes 5 arguments. But the
>   details of them (at least from the Python parlance) are not available.
>   My novice code to construct the Table looked like the following
>               tab_le = Table ([Str("This is the title of the table")], #
>   Table caption?
>                               ["left", "left"], # Alignment?
>                               [0.5, 0.5], # Relative width of the
>   columns?
>                               [Str("C1"), Str("C2")], #Column Header
>   name?
>                               [   # Table rows?
>                                  [Str("A1"), Str("B1")],
>                                  [Str("A2"), Str("B2")],
>                                  [Str("A3"), Str("B3")]
>                               ] );
>    With that code, i get the following error
>   >>>>
>   Error in $[373][0]: expected Object, encountered String
>   <<<<<
>   I am sure i am grossly off in the constructor. Can someone help me to
>   create Table?
>   Thanks and with best regards,
>   Nizam
>
>   --
>   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 [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To post to this group, send email to
>   [2]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To view this discussion on the web visit
>   [3]https://groups.google.com/d/msgid/pandoc-discuss/1be02d85-bd95-4709-
>   82f8-f6a5460930c6%40googlegroups.com.
>   For more options, visit [4]https://groups.google.com/d/optout.
>
>References
>
>   1. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   2. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   3. https://groups.google.com/d/msgid/pandoc-discuss/1be02d85-bd95-4709-82f8-f6a5460930c6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer
>   4. https://groups.google.com/d/optout


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

* Re: Pandoc Python filter + Table constructor
       [not found]     ` <20171104230532.GC97257-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
@ 2017-11-06  4:15       ` Nizamudheen Ahmed
       [not found]         ` <CA+zEWHCd+EGXRoWsJcxk0hb_fn2JpWsmVuCnmKJz5ge6FzFCjw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Nizamudheen Ahmed @ 2017-11-06  4:15 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Thanks John, Kolen.

@Kolen, my use-case is simple.

I have users of my filter to describe "situation". The "situation"
description itself is free-flow (can use any markdown foramtting scheme and
such, except the description itself not contain markdown header). The
"situation" is associated with one or more "tags".

My current idea is to use the <div> ...</div> block container to describe
the "situation. And the "tags" are annotated as div-kvs. In the filter, i
would like to create a table for each "situation". The table should look
like the following

+------------------------------------+-----------------------------------------+
| Situation Name                   | <Name of the situation >          |
+------------------------------------+-----------------------------------------+
| Tag1 Key                             | Tag1 Value
      |
+------------------------------------+-----------------------------------------+
| Tag2 Key                             | Tag2 Value
      |
+------------------------------------+-----------------------------------------+

Hence, i require to generate a table for each div with ['situation' in
div.classes].

Any comments/suggestion in my approach is welcome.

Thanks and with best regards,
Nizam


On Sun, Nov 5, 2017 at 4:35 AM, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:

> If you're using the pandocfilters library, I suggest you
> check out the alternative library panflute, which is more
> pythonic and easier to use.
>
> +++ Nizamudheen Ahmed [Nov 04 17 08:34 ]:
>
>>   Hi folks,
>>   I am new to Pandoc. I am trying to write a filter using Python. I
>>   wanted to create and return a "Table" as part of the filter function. I
>>   understood that the Table constructor takes 5 arguments. But the
>>   details of them (at least from the Python parlance) are not available.
>>   My novice code to construct the Table looked like the following
>>               tab_le = Table ([Str("This is the title of the table")], #
>>   Table caption?
>>                               ["left", "left"], # Alignment?
>>                               [0.5, 0.5], # Relative width of the
>>   columns?
>>                               [Str("C1"), Str("C2")], #Column Header
>>   name?
>>                               [   # Table rows?
>>                                  [Str("A1"), Str("B1")],
>>                                  [Str("A2"), Str("B2")],
>>                                  [Str("A3"), Str("B3")]
>>                               ] );
>>    With that code, i get the following error
>>   >>>>
>>   Error in $[373][0]: expected Object, encountered String
>>   <<<<<
>>   I am sure i am grossly off in the constructor. Can someone help me to
>>   create Table?
>>   Thanks and with best regards,
>>   Nizam
>>
>>   --
>>   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 [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>   To post to this group, send email to
>>   [2]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>   To view this discussion on the web visit
>>   [3]https://groups.google.com/d/msgid/pandoc-discuss/1be02d85-bd95-4709-
>>   82f8-f6a5460930c6%40googlegroups.com.
>>   For more options, visit [4]https://groups.google.com/d/optout.
>>
>> References
>>
>>   1. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>   2. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>   3. https://groups.google.com/d/msgid/pandoc-discuss/1be02d85-bd
>> 95-4709-82f8-f6a5460930c6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&
>> utm_source=footer
>>   4. https://groups.google.com/d/optout
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pandoc-discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/pandoc-discuss/OBlbFj5HJ9I/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/pandoc-discuss/20171104230532.GC97257%40Johns-MacBook-Pro.local.
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CA%2BzEWHCd%2BEGXRoWsJcxk0hb_fn2JpWsmVuCnmKJz5ge6FzFCjw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Pandoc Python filter + Table constructor
       [not found]         ` <CA+zEWHCd+EGXRoWsJcxk0hb_fn2JpWsmVuCnmKJz5ge6FzFCjw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-11-06 11:03           ` Kolen Cheung
       [not found]             ` <ae54a6c7-f694-4337-87d6-15178ab3f18d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Kolen Cheung @ 2017-11-06 11:03 UTC (permalink / raw)
  To: pandoc-discuss

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

Interesting. I think panflute would be a good fit. Try reading the panflute documentation first. There’s an example on csv table that can show you how to manipulate table elements. You can also checkout the source of pantable.py, which is inspired by the csv example, and is more sophisticated. Other examples in the panflute documentation also shows you how to capture a certain elements (possibly with attributes) in general.

When writing a filter, sometimes it is useful to see the AST of a MWE. Pandoc has the native and json output, while the filters see the JSON, the native is more readable. panflute also has a helper script (I think in the panflute filters repo) that can print the “panflute AST”, which will even be more useful if you use panflute. (panflute basically parses pandoc’s AST into its own using OOP, or in other words, a representation of pandoc’s AST using Python objects.)

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ae54a6c7-f694-4337-87d6-15178ab3f18d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: Pandoc Python filter + Table constructor
       [not found]             ` <ae54a6c7-f694-4337-87d6-15178ab3f18d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2017-11-13  6:08               ` Nizamudheen Ahmed
       [not found]                 ` <CA+zEWHBcdnzHekVNY3Tdi4qZCkwbgqt4PWAQKYXOzyXmHtAn2Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Nizamudheen Ahmed @ 2017-11-13  6:08 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Thanks Kolen. I will take your suggestion forward, and keep you posted.



On Mon, Nov 6, 2017 at 4:33 PM, Kolen Cheung <christian.kolen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:

> Interesting. I think panflute would be a good fit. Try reading the
> panflute documentation first. There’s an example on csv table that can show
> you how to manipulate table elements. You can also checkout the source of
> pantable.py, which is inspired by the csv example, and is more
> sophisticated. Other examples in the panflute documentation also shows you
> how to capture a certain elements (possibly with attributes) in general.
>
> When writing a filter, sometimes it is useful to see the AST of a MWE.
> Pandoc has the native and json output, while the filters see the JSON, the
> native is more readable. panflute also has a helper script (I think in the
> panflute filters repo) that can print the “panflute AST”, which will even
> be more useful if you use panflute. (panflute basically parses pandoc’s AST
> into its own using OOP, or in other words, a representation of pandoc’s AST
> using Python objects.)
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pandoc-discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/pandoc-discuss/OBlbFj5HJ9I/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pandoc-discuss/ae54a6c7-f694-4337-87d6-15178ab3f18d%
> 40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CA%2BzEWHBcdnzHekVNY3Tdi4qZCkwbgqt4PWAQKYXOzyXmHtAn2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Pandoc Python filter + Table constructor
       [not found]                 ` <CA+zEWHBcdnzHekVNY3Tdi4qZCkwbgqt4PWAQKYXOzyXmHtAn2Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-11-14 11:26                   ` Nizamudheen Ahmed
       [not found]                     ` <CA+zEWHBp2oiKbUVih9nM-LjVv_Kxti6t7uZ356_ScAdxkMMzUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Nizamudheen Ahmed @ 2017-11-14 11:26 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Hi Kolen,

I am trying to convert a "convenience layer" into a "div" block using
panflure.

I would ideally want my .md file to contains block elements of nature

<div classes="situation, id=".." >
    any_legal_md_content
</div>

One of my intent is to avoid the .md file appear as html file. So, i wanted
to declare a "convenience layer" where the contents of a div is
encapsulated using "HorizontalRule"

Example

*****
   any_legal_md_content
*****

And, i would like to create a filter that converts the "convenience layer"
to "div based block". Because, i have a number of other filters that work
based of "div based blocks".

At very high level, i assume this conversion is plausible using panflute.
Is mu assumption correct?

My logic is to have a minor state machine in the filter, wherein i create
an instance of "class Div(Block)" on encountering a HorizontalRule. This
state machine shall "append" all elements into this instance of "class
Div(Block)" until i encounter the subsequent HorizontalRule. As i encounter
this subsequent HorizontalRule, i intend to return the created Div block.

That is my high level approach.

This approach requires me to "append" all "element" that encounter between
the HorizontalRule into the Div(Block) instance. I found that the
Div.content.append method allows elements of base type "Block" to be
appended. And, the elements of base type "Inline" can't be. So, i have
stumbled upon identifying ways to all "all" elements to the Div(Block)
instance. Can you help me with this?

BR/Nizam


On Mon, Nov 13, 2017 at 11:38 AM, Nizamudheen Ahmed <nizam.ahmed-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:

> Thanks Kolen. I will take your suggestion forward, and keep you posted.
>
>
>
> On Mon, Nov 6, 2017 at 4:33 PM, Kolen Cheung <christian.kolen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
>
>> Interesting. I think panflute would be a good fit. Try reading the
>> panflute documentation first. There’s an example on csv table that can show
>> you how to manipulate table elements. You can also checkout the source of
>> pantable.py, which is inspired by the csv example, and is more
>> sophisticated. Other examples in the panflute documentation also shows you
>> how to capture a certain elements (possibly with attributes) in general.
>>
>> When writing a filter, sometimes it is useful to see the AST of a MWE.
>> Pandoc has the native and json output, while the filters see the JSON, the
>> native is more readable. panflute also has a helper script (I think in the
>> panflute filters repo) that can print the “panflute AST”, which will even
>> be more useful if you use panflute. (panflute basically parses pandoc’s AST
>> into its own using OOP, or in other words, a representation of pandoc’s AST
>> using Python objects.)
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "pandoc-discuss" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/pandoc-discuss/OBlbFj5HJ9I/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/pandoc-discuss/ae54a6c7-f694-4337-87d6-15178ab3f18d%40go
>> oglegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CA%2BzEWHBp2oiKbUVih9nM-LjVv_Kxti6t7uZ356_ScAdxkMMzUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Pandoc Python filter + Table constructor
       [not found]                     ` <CA+zEWHBp2oiKbUVih9nM-LjVv_Kxti6t7uZ356_ScAdxkMMzUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-12-11  7:51                       ` Kolen Cheung
  0 siblings, 0 replies; 8+ messages in thread
From: Kolen Cheung @ 2017-12-11  7:51 UTC (permalink / raw)
  To: pandoc-discuss


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

Hey, sorry I didn't get back to you. I was very busy and will continue to 
be for at least 1.5 more month as I started traveling. May be you can try 
getting in touch with panflute author Sergio? He's also around in pandoc 
discuss.

On Tuesday, November 14, 2017 at 7:26:49 PM UTC+8, Nizamudheen Ahmed wrote:
>
> Hi Kolen,
>
> I am trying to convert a "convenience layer" into a "div" block using 
> panflure.
>
> I would ideally want my .md file to contains block elements of nature 
>
> <div classes="situation, id=".." > 
>     any_legal_md_content
> </div>
>
> One of my intent is to avoid the .md file appear as html file. So, i 
> wanted to declare a "convenience layer" where the contents of a div is 
> encapsulated using "HorizontalRule"
>
> Example
>
> *****
>    any_legal_md_content
> *****
>
> And, i would like to create a filter that converts the "convenience layer" 
> to "div based block". Because, i have a number of other filters that work 
> based of "div based blocks". 
>
> At very high level, i assume this conversion is plausible using panflute. 
> Is mu assumption correct?
>
> My logic is to have a minor state machine in the filter, wherein i create 
> an instance of "class Div(Block)" on encountering a HorizontalRule. This 
> state machine shall "append" all elements into this instance of "class 
> Div(Block)" until i encounter the subsequent HorizontalRule. As i encounter 
> this subsequent HorizontalRule, i intend to return the created Div block. 
>
> That is my high level approach.
>
> This approach requires me to "append" all "element" that encounter between 
> the HorizontalRule into the Div(Block) instance. I found that the 
> Div.content.append method allows elements of base type "Block" to be 
> appended. And, the elements of base type "Inline" can't be. So, i have 
> stumbled upon identifying ways to all "all" elements to the Div(Block) 
> instance. Can you help me with this?
>
> BR/Nizam
>
>
> On Mon, Nov 13, 2017 at 11:38 AM, Nizamudheen Ahmed <nizam...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 
> <javascript:>> wrote:
>
>> Thanks Kolen. I will take your suggestion forward, and keep you posted.
>>
>>
>>
>> On Mon, Nov 6, 2017 at 4:33 PM, Kolen Cheung <christi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 
>> <javascript:>> wrote:
>>
>>> Interesting. I think panflute would be a good fit. Try reading the 
>>> panflute documentation first. There’s an example on csv table that can show 
>>> you how to manipulate table elements. You can also checkout the source of 
>>> pantable.py, which is inspired by the csv example, and is more 
>>> sophisticated. Other examples in the panflute documentation also shows you 
>>> how to capture a certain elements (possibly with attributes) in general.
>>>
>>> When writing a filter, sometimes it is useful to see the AST of a MWE. 
>>> Pandoc has the native and json output, while the filters see the JSON, the 
>>> native is more readable. panflute also has a helper script (I think in the 
>>> panflute filters repo) that can print the “panflute AST”, which will even 
>>> be more useful if you use panflute. (panflute basically parses pandoc’s AST 
>>> into its own using OOP, or in other words, a representation of pandoc’s AST 
>>> using Python objects.)
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "pandoc-discuss" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/pandoc-discuss/OBlbFj5HJ9I/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to 
>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>.
>>> To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 
>>> <javascript:>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pandoc-discuss/ae54a6c7-f694-4337-87d6-15178ab3f18d%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/5b028450-1c43-4f39-b267-93553169e600%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

end of thread, other threads:[~2017-12-11  7:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-04 15:34 Pandoc Python filter + Table constructor Nizamudheen Ahmed
     [not found] ` <1be02d85-bd95-4709-82f8-f6a5460930c6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-04 19:34   ` Kolen Cheung
2017-11-04 23:05   ` John MacFarlane
     [not found]     ` <20171104230532.GC97257-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2017-11-06  4:15       ` Nizamudheen Ahmed
     [not found]         ` <CA+zEWHCd+EGXRoWsJcxk0hb_fn2JpWsmVuCnmKJz5ge6FzFCjw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-06 11:03           ` Kolen Cheung
     [not found]             ` <ae54a6c7-f694-4337-87d6-15178ab3f18d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-13  6:08               ` Nizamudheen Ahmed
     [not found]                 ` <CA+zEWHBcdnzHekVNY3Tdi4qZCkwbgqt4PWAQKYXOzyXmHtAn2Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-14 11:26                   ` Nizamudheen Ahmed
     [not found]                     ` <CA+zEWHBp2oiKbUVih9nM-LjVv_Kxti6t7uZ356_ScAdxkMMzUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-12-11  7:51                       ` Kolen Cheung

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