Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there solution to add custom style for lists with panflute ? #227

Open
ant0nT opened this issue Jan 29, 2023 · 2 comments
Open

Is there solution to add custom style for lists with panflute ? #227

ant0nT opened this issue Jan 29, 2023 · 2 comments

Comments

@ant0nT
Copy link

ant0nT commented Jan 29, 2023

I search solution to fix the problem described in https://stackoverflow.com/questions/58024749/how-to-format-lists-in-pandoc-generated-docx-documents.
I've tried to write solution by myself with panflute, but honestly hasn't gotten any success. Is it possible to write full script or script with pseudocode to replace styles of lists?

upd: According to https://stackoverflow.com/questions/43730436/pandoc-replace-heading-with-custom-style-for-word-docx

've written this code:

from panflute import *

def action( elem, doc ):
if isinstance( elem, BulletList ):
#return Div( elem, attributes={'custom-style': 'Header{}'.format(elem.level)} )
return Div( BulletList(*elem.content), attributes={'custom-style': 'List Bullet {}'.format(elem.level)} )

def main(doc=None):
return run_filter( action, doc=doc )

if name == "main":
main()

but I get error : AttributeError: 'BulletList' object has no attribute 'level'

Is there solution to find out BulletList element level?

@lewer
Copy link
Contributor

lewer commented Feb 1, 2023

What you are trying to do is not very clear. What do you mean by BulletList level? Headers have a level (Header1, Header2,...) but BulletList don't.

@ant0nT
Copy link
Author

ant0nT commented Feb 1, 2023

If I put tab before asterics in markdown like this:

* item1
* item2
\t* item 2.1

pandoc converting it in docx like this

{black circle} item 1
{black circle} item 2
\t {white circle} item 2.1

and for ordered list:

1. item 1
1. item 2
\t1. item 2.1
\t1. item 2.2

converting it to:

1. item1
2. item 2
\t1. item 2.1
\t2. item 2.2

Preview programs display lists in md like pandoc converting it.

But all lists and tables in docx document have "compact" style, what doesn't let me to customise their representations in docx individually

p.s. I've written python script, which replaces lists to paragraphs with custom styles in md, but don't working properly with sorted lists, because it doesn't start a new list numbering from "1" and continue numbering

p.s. Maybe I should to direct this issue to pandoc developers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants