[TOC] get an attribute directly from a style

Previous topic - Next topic

PK

Hi,

For doing a TOC, you need attributes as entry points for the table. This is a heavy and repetitively job to do by hands, especially when you have a regular structure like a book, which is governed by fixed rules like styles.

Is it possible to (easily) associate an attribute with a dedicated style, with the content of the style (i.e. all the characters that match the style) as the value?

I think this is not too much difficult to develop as a script, but I can't imagine that is not already done  ;D


a.l.e

nö, that won't do it.

this one will do it:

https://github.com/aoloe/scribus-script-repository/tree/master/table-of-contents

there is a forum thread about it:

https://forums.scribus.net/index.php/topic,4480.0.html

in the long term, i'd like to have something built into scribus, but i'm not sure i want to do that as long as there is no commitment on replacing the current one with that.

PK

Giusto  :)

Your script is nice and works perfectly.

I notice a light bug, but may be it comes from me and the way I run Scribus.

When I need to force a section not to stay on the bottom of a page, for not having a orphaned title, I add an frame jump before, to move it at the top of the next page. Your script considers this sign like a part of a title (its style is the same as the title, because I place it on the same line, in front of the value of the title) and adds an entry in the TOC (so, a wide entry!). There is also a Scribus bug: when the TOC entry value is wide, the next entries are not printed...

May be must I correct the way I run Scribus in inserting an other jump sign?

Thanks in any case: very good job  :D   

PK

Correction: this is not a wide entry, but an entry with the frame jump, so the TOC is divided as many times that there are frame jump entries. So, there is no bug for Scribus in the TOC: all the entries are well here, but there are in many text frames...

a.l.e

i have updated the script to ignore the column and frame breaks:

https://github.com/aoloe/scribus-script-repository/tree/master/table_of_contents

(and i've also renamed the script to match the python conventions...)

can you please test it and, if you find other bugs, upload a sample .sla file with the specific text?

PK

It is OK like this: nice work  8)

You changed the name of your script by transforming dash in underscore, is it normal?

You may add an other functionality. I have added in the titles sometimes line breaks for a perfect layout when the title are too long. I removed it from the toc, because the styles are very different and the police is smaller. I don't know if it is a generic functionality indeed!

Thank you.

I don't understand why your scripts are not delivered with Scribus...

a.l.e

concerning the move to _: i'm renaming all my scripts to use _ instead of -... personally, i prefer the dashes, but python advocates the use of _ (and the linter keeps telling me that).

when developing the integration into the menus (https://bugs.scribus.net/view.php?id=15579) i decided to only actively support what PEP says and to slowly rename all my scripts to match that.

concerning the new lines: i have not worked with table of contents in many years but, yes, i agree that it should at least be an option to remove them from the titles.
i just wonder a bit how to do it.

should be the default or if it should even be the only behavior?

a possible behavior might also be, to drop what is after the new line (i think i have had such cases in my distant past...)

and, finally, about the scripts distributed with scribus: personally, i don't think i've ever used any of the scripts that are coming with scribus.
i'm not fond of scripts that have complex UIs and try to cover every possible workflow. i prefer scripts tailored to specific tasks.

imo, scribus should make it easy for the user to run

- their own scripts
- scripts from collections they like
- scripts provided by their "IT".

my patch adding the user's scripts to the navigation goes in this direction... but who knows when well it will be reviewed...

a.l.e

the script now optionally strips newlines or truncates after the first newline...

one can pick the option by setting the attribute on the target frame.

PK


MrB

1.7.0.svn now has a style based TOC generator that I added this evening.

a.l.e

#11
hi craig

nice start.

personally, i still believe, that the attribute TOC must go away. it adds useless complexity both in the code and in the UI.

what are your plans for further features?
the current state does not seem production ready yet : - )

toc-mrb-01.png

p.s.: you can read this thread and https://forums.scribus.net/index.php/topic,4480.0.html to find some edge cases that need to be supported... (the README and the python script might also be helpful...)

toc-mrb-02.png

MrB

Please share those files. It looks like you have a text frame style and a style on text.

MrB

#13
I also uploaded a sample file on
https://bugs.scribus.net/view.php?id=5975

Working well there


MrB