View Issue Details

IDProjectCategoryView StatusLast Update
0005975ScribusStory Editor / Text Framespublic2019-04-09 08:57
Reportermecirt Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status newResolutionopen 
PlatformAMD64OSLinuxOS VersionOpenSuSE 10.2
Product Version1.3.4 
Target VersionFixed in Version 
Summary0005975: Wish: generate TOC from paragraph styles
DescriptionThe current TOC editor unfortunately isn't very useful for me. I want to use Scribus to create book layouts, where text may flow between frames as adjustments are made. Thus, text headings (which appear in the TOC) can also flow from one frame to another, and marking a frame as a TOC item is not sufficient, because I do not know which frame a heading will end up in.

Therefore, I'd like to see the TOC generator functionality extended to be able to extract TOC information from paragraph styles - in particular, to be able to mark a particular paragraph style as "include in TOC", and then all paragraphs that get assigned this particular style (a Heading one) would get added to the TOC, with their page number included.

To my understanding, the current TOC generator is not able to do this.

/ Tomas
TagsNo tags attached.
PatchNo

Relationships

related to 0004484 assignedcezaryece TOC generation: Several issues 
related to 0001371 assignedcezaryece Considering writing plugin to generate TOCs, Indexes, and "Continued on pg ... " messages 
related to 0001773 closedcbradney Extra attributes on frames and documents 
parent of 0015049 confirmed Numbered Headings in different Text-Frames, when opening the document ... 
has duplicate 0008796 assignedcezaryece [feature request] more usable TOC 
has duplicate 0015640 closedjghali Wish: generate TOC from paragraph styles 
Not all the children of this issue are yet resolved or closed.

Activities

janD

2008-01-18 21:03

reporter   ~0018651

Last edited: 2008-01-18 21:04

This is my most wanted feature too.
A Programm without Style-Based TOC-Generation is almost useless for longer or structured Publications.

rdevries

2008-01-19 06:27

reporter   ~0018652

I agree that it would be a great feature.

louisdesjardins

2008-01-19 14:59

developer   ~0018656

Great idea!

Same could apply to Index, through character style (word style?). What do you think?

I guess that from the programming point of view, once we have that tag possibility set for paragraph style, the path is cleared for extending the similar feature to other kinds of styles. Right?

rdevries

2008-01-20 10:07

reporter   ~0018670

Yes indeed. It also would be handy if you can use other kind of styles in your TOC.

janD

2008-01-27 16:35

reporter   ~0018744

Once we have a function to locate specific styles on a page, it should be no problem to generate indexes too.
The problem is: The feature seems to be not planned. Endnotes and index is "acknowledged", but it is not clear, if "our" feature (status "new")is coming, although I think that the index-Feature-functions should make a style-based TOC possible as well.
TOC is mentioned in the Scribus-Roadmap (1.3.9) but it is "done" (so it is the one we have now)
It would be good if someone could find out if a style-based TOC-generation is planned. (maybe for the 1.3.9 ?)

Thaddeus

2011-01-06 23:24

reporter   ~0025303

Here is a Scripter script that could be adapted to do a TOC. I wrote it to search for string across the entire document.

Thaddeus

2011-01-06 23:24

reporter  

FindInTxtFrames Script & Example.zip (11,168 bytes)

cezaryece

2011-01-10 11:03

developer   ~0025320

Style based TOC is under construction, see http://bugs.scribus.net/view.php?id=8796

JLuc

2017-11-29 19:04

developer   ~0044677

Thaddeus, your script hangs on scribus 1.5.3
It runs, messages "Finished" "All Done. Total hits found = 25" but never comes back to me.
I have to kill scribus.

Do you have a possible fix or an idea of what is the issue ?

JLuc

2017-11-29 19:23

developer   ~0044678

Last edited: 2017-11-29 19:23

View 2 revisions

OK i fixed the issue.
Here is updated script.
It runs for scribus 1.5.4 svn.
As is, it's far from being user friendly, but it's a possible start point to create an index builder. And there is more to do to create a TOC.



FindInTxtFrames.py (6,398 bytes)

michelv

2017-11-30 07:32

reporter   ~0044681

JLuc, nice start. For a TOC, a regular expression on a style would be the thing to have. Is there documentation around on how styles are coded into the files?

JLuc

2017-11-30 08:42

developer   ~0044682

Last edited: 2017-11-30 08:45

View 2 revisions

You're right.
Scribus .SLA files are XML-like files : open with a plain text editor and spot the place where a style is used.

The output of the script, as is, is not friendly and has to be totaly manualy reworked each time.
I've had an idea to improve this :
the user could provide, on the first page, a special frame with a dedicated Id "IndexTemplate" or "TOCTemplate".
That frame would contain a one-line paragraph with user-choosen styles and with place holders like
- %P for page number,
- %T for text (or title)
- %F for frame name (in case it's usefull for somebody),
Then the script would read that IndexTemplate frame,
find the paragraph text,
replace the place holders with the found values for each found occurence
and paste the result at the end of the result frame.

Then some more refinement would be required :
- For indexes, duplicate pages numbers should only be placed once
- For TOC, not only 1 but several styles should be searched, each corresponding to a title level of the document, and there should be also one paragragh in the TOCTemplate for each TOC level (= for each searched style).
Not sure but it could be this would benefit of enriching the Template frame syntax.

That would provide a general yet powerfull way of creating TOCs and Indexes

michelv

2017-11-30 09:25

reporter   ~0044683

Just looked into the XML:
            <StoryText>
                <DefaultStyle NumerationName="<local block>"/>
                <tab/>
                <ITEXT CH="Introduction"/>
                <para PARENT="Header1" NumerationName="<local block>"/>
ETC

Header1 is my style for a H1 title. That could be linked automatic/manually. Manual entry is error probe, but ok for a start I guess.

Shouldn't be hard to find this; only thing to notice is that the actual text is in a previous block from the Header1 definition.
Another thing I notice: the numbering is done somewhere else. For a TOC this should be replicated exactly.

For automation: The styles could be found from the doc with loadStylesFromFile(...) ?
I don't see a predefined API call in the documentation to simply get the style of a paragraph from the text.

Formatting the TOC:
The TOC entries would probably have a style applied per level within the TOC. For a start it wouldn't be too bad to do this manually after the TOC entries are placed into the frame.
Setting a style on the generated TOC entry could be done with setStyle() ? (if objects are also the strings generated)

There is an open bug (0015049) on the creation of the numbering throughout the document. Probably that same function should be called for the TOC creation?

JLuc

2017-11-30 10:10

developer   ~0044684

Last edited: 2017-11-30 10:11

View 2 revisions

Ouch : Not all titles have numbering, but knowing the final numbering could be a blocker when required. It reminds me of 0014605 about knowing mark's page numbers .

ale

2017-12-02 16:15

manager   ~0044699

https://github.com/aoloe/scribus-plugin-tableofcontents will probably make some progress very soon...

it's based on the one mentioned by cezary, but "simpler".

as far as i know (as far as i recall) it's not "easy" to do it in python, since you cannot know on which page a bunch of text (a paragraph) is...

izaius

2019-04-08 22:54

reporter   ~0046093

Any word on this one? It seems it was added in cezaryece's custom branch, which is on Git. Is this going to be added into the main build any time soon?

ale

2019-04-09 08:00

manager   ~0046095

cezary's version was a bit "weak".

my "version" -- while being somehow based on cezaary's work --is simpler and more solid... but i'm building it upon a new scripter API that i'm creating "for it".
so it takes time...

collaboration is welcome.

Issue History

Date Modified Username Field Change
2007-07-05 11:05 mecirt New Issue
2007-07-05 15:04 christoph_s Relationship added related to 0004484
2007-07-05 15:04 christoph_s Relationship added related to 0001371
2007-07-05 15:04 christoph_s Relationship added related to 0001773
2008-01-18 21:03 janD Note Added: 0018651
2008-01-18 21:04 janD Note Edited: 0018651
2008-01-19 06:27 rdevries Note Added: 0018652
2008-01-19 14:59 louisdesjardins Note Added: 0018656
2008-01-20 10:07 rdevries Note Added: 0018670
2008-01-27 16:35 janD Note Added: 0018744
2008-02-05 18:06 christoph_s Status new => acknowledged
2010-03-16 15:01 mhanski Relationship added has duplicate 0008796
2011-01-06 23:24 Thaddeus Note Added: 0025303
2011-01-06 23:24 Thaddeus File Added: FindInTxtFrames Script & Example.zip
2011-01-10 11:03 cezaryece Note Added: 0025320
2012-06-18 20:13 ale Assigned To => cezaryece
2012-06-18 20:13 ale Status acknowledged => assigned
2015-09-17 20:08 Kunda Category Story Editor / Text Frames => Story Ed/Txt Frames
2015-09-17 20:12 Kunda Category Story Ed/Txt Frames => Story Editor / Text Frames
2017-11-29 18:54 JLuc Assigned To cezaryece =>
2017-11-29 18:54 JLuc Status assigned => new
2017-11-29 18:54 JLuc Patch => No
2017-11-29 19:04 JLuc Note Added: 0044677
2017-11-29 19:23 JLuc File Added: FindInTxtFrames.py
2017-11-29 19:23 JLuc Note Added: 0044678
2017-11-29 19:23 JLuc Note Edited: 0044678 View Revisions
2017-11-30 07:32 michelv Note Added: 0044681
2017-11-30 08:42 JLuc Note Added: 0044682
2017-11-30 08:45 JLuc Note Edited: 0044682 View Revisions
2017-11-30 09:25 michelv Note Added: 0044683
2017-11-30 10:05 JLuc Relationship added parent of 0015049
2017-11-30 10:10 JLuc Note Added: 0044684
2017-11-30 10:11 JLuc Note Edited: 0044684 View Revisions
2017-12-02 16:15 ale Note Added: 0044699
2019-04-08 22:54 izaius Note Added: 0046093
2019-04-09 02:47 izaius Issue cloned: 0015640
2019-04-09 02:47 izaius Relationship added parent of 0015640
2019-04-09 08:00 ale Note Added: 0046095
2019-04-09 08:57 jghali Relationship replaced has duplicate 0015640