Re: [Tutor] need help generating table of contents

2018-08-28 Thread Albert-Jan Roskam
From: Tutor on behalf of Peter Otten <__pete...@web.de> Sent: Monday, August 27, 2018 6:43 PM To: tutor@python.org Subject: Re: [Tutor] need help generating table of contents   Albert-Jan Roskam wrote: > > From: Tutor on behalf > of Peter Otten <__pete...@web.de> Se

Re: [Tutor] need help generating table of contents

2018-08-27 Thread Peter Otten
Albert-Jan Roskam wrote: > > From: Tutor on behalf > of Peter Otten <__pete...@web.de> Sent: Friday, August 24, 2018 3:55 PM > To: tutor@python.org > >> The following reshuffle of your code seems to work: >> >> print('\r\n** Table of contents\r\n') >> pattern = '/Title \((.+?)\).+?/Page ([0-9]

Re: [Tutor] need help generating table of contents

2018-08-27 Thread Albert-Jan Roskam
From: Tutor on behalf of Peter Otten <__pete...@web.de> Sent: Friday, August 24, 2018 3:55 PM To: tutor@python.org > The following reshuffle of your code seems to work: > > print('\r\n** Table of contents\r\n') > pattern = '/Title \((.+?)\).+?/Page ([0-9]+)(?:\s+/Count ([0-9]+))?' > > def pr

Re: [Tutor] need help generating table of contents

2018-08-25 Thread Cameron Simpson
On 24Aug2018 17:55, Peter Otten <__pete...@web.de> wrote: Albert-Jan Roskam wrote: I have Ghostscript files with a table of contents (toc) and I would like to use this info to generate a human-readable toc. The problem is: I can't get the (nested) hierarchy right. import re toc = """\ [ /Pag

Re: [Tutor] need help generating table of contents

2018-08-24 Thread Peter Otten
Albert-Jan Roskam wrote: > Hello, > > I have Ghostscript files with a table of contents (toc) and I would like to use this info to generate a human-readable toc. The problem is: I can't get the (nested) hierarchy right. > > import re > > toc = """\ > [ /PageMode /UseOutlines > /Page 1 > /

[Tutor] need help generating table of contents

2018-08-24 Thread Albert-Jan Roskam
Hello, I have Ghostscript files with a table of contents (toc) and I would like to use this info to generate a human-readable toc. The problem is: I can't get the (nested) hierarchy right. import re toc = """\ [ /PageMode /UseOutlines   /Page 1   /View [/XYZ null null 0]   /DOCVIEW pdfmark [ /