public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Daniel Shunfenthal <danshunfenthal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Scripting help, or how to set bullet list style for .docx formatting
Date: Tue, 13 Jun 2017 13:42:21 -0700 (PDT)	[thread overview]
Message-ID: <b1327704-3fd9-48da-b709-04e9e7267312@googlegroups.com> (raw)


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

I'm having trouble with writing a pandoc python filter.

When I convert from markdown to docx I'm using a custom reference to set 
styles. 
I can change most of the styles I want, except the bullet style, it isn't 
supported in the reference file. Default bullets only seem to only use "•" 
and "-" and repeats. I wanted to add a couple more bullets since my 
markdown file has a few levels.

If I read the docs correctly, the best way to do that would be to create a 
custom style and a filter to convert it. (but let me know if there is an 
easier way)
I made the custom style in the reference doc called "List Bullet" and if I 
surround my lists with a Div with the class name, it works for the first 
level at least.

I'm trying to make a python filter, but I am only just learning programming 
and I only know a very little python. I think this shouldn't be too hard to 
do, but I'm stuck. I've looked at a couple of the python examples, but I 
don't quite understand some things.

This is what I have so far. It works only on the first bullet of each list, 
and I sort of understand why but I do not know how to have it apply to the 
whole list and sub-lists. I also think I need to call each successive 
increment "List Bullet 2", "3" and so on.

FYI, got most of the code from the python filter examples on their github.
from pandocfilters import toJSONFilter, BulletList, Div, stringify, 
attributes

def deflists(key, value, format, meta):
    
    if key == 'BulletList':
        # Pretty sure this needs to loop through each value, but not sure 
how.
        return Div(["", [], [['custom-style', 'List Bullet']]], value[0])
        
# Is this on the right track? I think I need to recurse through the list?
def toDiv(bullets):
    return Div(["", [], [['custom-style', 'List Bullet']]], bullets)

if __name__ == "__main__":
    toJSONFilter(deflists)

-- 
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/b1327704-3fd9-48da-b709-04e9e7267312%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

                 reply	other threads:[~2017-06-13 20:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1327704-3fd9-48da-b709-04e9e7267312@googlegroups.com \
    --to=danshunfenthal-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).