Skip to content

Add ability to restart numbering #210

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yurac
Copy link

@yurac yurac commented Sep 24, 2015

No description provided.

@photuris
Copy link

Hi @yurac. I'm sorry to bother you. I'm trying to get ordered list resetting working, but attempting to do so while using the main python-docx distribution in my environment for now (waiting until such time as your patch, or a similar one, is incorporated).

Anyway, I just copy/pasted what you've got going on here: #25, and I'm trying to simply use it directly in my script.

However, my elements aren't renumbering between separated ordered lists, and I'm a bit stumped. Can I beg three minutes of your time?

Here's my clumsy attempt to use your method in-line in my script:
https://gist.github.com/photuris/8f71166deec7f8f5a774

No errors, just nothing's happening (I'd rather have errors). My two lists simply continue numbering, 1 2 3 4 5 6, rather than 1 2 3 1 2 3.

Thanks in advance! I'll be forever in your debt.

@yurac
Copy link
Author

yurac commented Jan 30, 2016

Hi,

I am not sure I understand your code. You can take my pull request as is
together with the example and see if it works for you. If it does not, you
will have to create a docx template corresponding to the example. Such as
adding there abstract numbering with id "10" as used in the example. Then
you can continue from there. You will probably have to read through
python-docx code and some of docx oxml documentation. There is another
project - olebole/python-docx that has a different solution for restart
numbering

Hi @yurac https://github.com/yurac. I'm sorry to bother you. I'm trying
to get ordered list resetting working, but attempting to do so while using
the main python-docx distribution in my environment for now (waiting until
such time as your patch, or a similar one, is incorporated).

Anyway, I just copy/pasted what you've got going on here: #25
#25, and I'm trying
to simply use it directly in my script.

However, my elements aren't renumbering between separated ordered lists,
and I'm a bit stumped. Can I beg three minutes of your time?

Here's my clumsy attempt to use your method in-line in my script:
https://gist.github.com/photuris/8f71166deec7f8f5a774

No errors, just nothing's happening (I'd rather have errors). My two lists
simply continue numbering, 1 2 3 4 5 6, rather than 1 2 3 1 2 3.

Thanks in advance! I'll be forever in your debt.


Reply to this email directly or view it on GitHub
#210 (comment)
.

@photuris
Copy link

photuris commented Feb 1, 2016

Ok, I figured it out.

  1. I had to poke around in the xml source for my template file, to figure
    out that the abstract numbering ID I needed was "12." So I hard-coded that
    in.
  2. I created a function called _reset_list() which manually adds XML
    elements to the first item in my list, to reset the numbering (which I
    deduced by poking around on the OpenXML spec on MSDN). I call this function
    on the first iteration of my item list.

Ugly, but it works, so for the time being I'm satisfied.

(Tangentially, I used a similar manual XML manipulation technique to edit
my template's header, found in headers1.xml in the source document).

Thank you for taking the time to respond.

On Sat, Jan 30, 2016 at 9:46 AM, yurac notifications@github.com wrote:

Hi,

I am not sure I understand your code. You can take my pull request as is
together with the example and see if it works for you. If it does not, you
will have to create a docx template corresponding to the example. Such as
adding there abstract numbering with id "10" as used in the example. Then
you can continue from there. You will probably have to read through
python-docx code and some of docx oxml documentation. There is another
project - olebole/python-docx that has a different solution for restart
numbering

Hi @yurac https://github.com/yurac. I'm sorry to bother you. I'm trying
to get ordered list resetting working, but attempting to do so while using
the main python-docx distribution in my environment for now (waiting until
such time as your patch, or a similar one, is incorporated).

Anyway, I just copy/pasted what you've got going on here: #25
#25, and I'm trying
to simply use it directly in my script.

However, my elements aren't renumbering between separated ordered lists,
and I'm a bit stumped. Can I beg three minutes of your time?

Here's my clumsy attempt to use your method in-line in my script:
https://gist.github.com/photuris/8f71166deec7f8f5a774

No errors, just nothing's happening (I'd rather have errors). My two lists
simply continue numbering, 1 2 3 4 5 6, rather than 1 2 3 1 2 3.

Thanks in advance! I'll be forever in your debt.


Reply to this email directly or view it on GitHub
<
#210 (comment)

.


Reply to this email directly or view it on GitHub
#210 (comment)
.

@yurac
Copy link
Author

yurac commented Feb 1, 2016

Good to hear that you got it working. I also had to spend some time to make
it work. What I did is a script that converts a subset of asciidoc to docx.
Works good for me since then.
On Feb 1, 2016 9:47 PM, "Joshua Pruitt" notifications@github.com wrote:

Ok, I figured it out.

  1. I had to poke around in the xml source for my template file, to figure
    out that the abstract numbering ID I needed was "12." So I hard-coded that
    in.
  2. I created a function called _reset_list() which manually adds XML
    elements to the first item in my list, to reset the numbering (which I
    deduced by poking around on the OpenXML spec on MSDN). I call this function
    on the first iteration of my item list.

Ugly, but it works, so for the time being I'm satisfied.

(Tangentially, I used a similar manual XML manipulation technique to edit
my template's header, found in headers1.xml in the source document).

Thank you for taking the time to respond.

On Sat, Jan 30, 2016 at 9:46 AM, yurac notifications@github.com wrote:

Hi,

I am not sure I understand your code. You can take my pull request as is
together with the example and see if it works for you. If it does not,
you
will have to create a docx template corresponding to the example. Such as
adding there abstract numbering with id "10" as used in the example. Then
you can continue from there. You will probably have to read through
python-docx code and some of docx oxml documentation. There is another
project - olebole/python-docx that has a different solution for restart
numbering

Hi @yurac https://github.com/yurac. I'm sorry to bother you. I'm
trying
to get ordered list resetting working, but attempting to do so while
using
the main python-docx distribution in my environment for now (waiting
until
such time as your patch, or a similar one, is incorporated).

Anyway, I just copy/pasted what you've got going on here: #25
#25, and I'm
trying
to simply use it directly in my script.

However, my elements aren't renumbering between separated ordered lists,
and I'm a bit stumped. Can I beg three minutes of your time?

Here's my clumsy attempt to use your method in-line in my script:
https://gist.github.com/photuris/8f71166deec7f8f5a774

No errors, just nothing's happening (I'd rather have errors). My two
lists
simply continue numbering, 1 2 3 4 5 6, rather than 1 2 3 1 2 3.

Thanks in advance! I'll be forever in your debt.


Reply to this email directly or view it on GitHub
<

#210 (comment)

.


Reply to this email directly or view it on GitHub
<
#210 (comment)

.


Reply to this email directly or view it on GitHub
#210 (comment)
.

@akobler
Copy link

akobler commented Jun 6, 2016

Hi, first of all thanks for all your work.

What is the state of this pull request? Is something missing or not working correctly? I would be very interested in having this feature on master :-)

Best, Andi

@yurac
Copy link
Author

yurac commented Jun 6, 2016

Hi,

It works for me but requires some changes in the user docx template.
Would be nice if this or other solution is integrated into python-docx.

Best,
Yuri

On Mon, Jun 6, 2016 at 12:43 PM, Andreas Kobler notifications@github.com
wrote:

Hi, first of all thanks for all your work.

What is the state of this pull request? Is something missing or not
working correctly? I would be very interested in having this feature on
master :-)

Best, Andi


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#210 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABCdOLmLBcX6obEwlNkfjjjyu6ispOHwks5qI-vJgaJpZM4GC5wB
.

whtsky added a commit to whtsky/python-docx that referenced this pull request Oct 23, 2019
@yash-dalmia
Copy link

Any update on merge?

@jjalonsoc
Copy link

Any update on this, is there a fork to check, there are no commits in the Master branch for 2 years.

@mzaveiro
Copy link

mzaveiro commented Jul 5, 2024

It's an old PR, but it would be really nice if python-docx could support restating a number list. Is there anything left to be done for this PR to be merged? I can help if you want.

@sweet-smile-1
Copy link

hello i want to achieve this:
a xxxx
b xxxx
c xxxx
a yyy
b yyy
c yyy
can anyone help me

@sweet-smile-1
Copy link

这是一个旧的 PR,但如果可以支持重述数字列表,那就太好了。合并此 PR 还需要做些什么吗?如果你愿意,我可以帮忙。python-docx

hello i want to achieve this:
a xxxx
b xxxx
c xxxx
a yyy
b yyy
c yyy
can anyone help me

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

Successfully merging this pull request may close these issues.

7 participants