Skip to content

Added new add_list method to enhance lists support. #110

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

Closed

Conversation

mohamedattahri
Copy link

Added support for multiple numbered/bullet lists with a new add_list api method.

Fixes issue #25.

  • BlockItemContainer has been improved with a new method to generate unique numId values
  • Created a new ListParagraph proxy that supports adding Paragraph instances sharing the same numId values.
  • Paragraph has a couple of new getters/setters to access numId and ilvl

TODO:

  • Tests
  • documentation

Example:

    document = Document()
    a_list = document.add_list(style='ListParagraph')
    # add_item() behaves exactly like Document.add_paragraph()
    a_list.add_item('first')
    a_list.add_item().add_run('second').bold = True

    # You can even create sub-lists to increase the indentation of sub-items
    b_list = a_list.add_list()
    b_list.add_item('one')
    b_list.add_item('two')

    # List of lists in the document
    print(len(document.lists))

Added support for multiple numbered/bullet lists with a new add_list
method. ListParagraph is a proxy container that supports adding
Paragraph instances sharing the same numId.
@mohamedattahri mohamedattahri changed the title Added new add_list method to enhance list support. Added new add_list method to enhance lists support. Nov 27, 2014
Mohamed Attahri added 4 commits November 27, 2014 18:12
@Sebastancho
Copy link

How can I use this code in my project?

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

Successfully merging this pull request may close these issues.

3 participants