Copy link to clipboard
Copied
Hi there,
While still a begginer with scripting, I'm looking forward to learn some more about scripting and ID.
For the time being, I'm having a time-consuming routine that I would like to change thanks to scripts.
Here's where I need help:
- I need to sort alphabetically text blocks based on a Title (Paraph.style Title 1, for instance, the Level 1, if I may say). I cannot use the well known scripts sort-alpha or any I've found on the web, like the one included in ID, because my text blocks include sub-paragraphs, with various para.styles. When using them, the sub-paragraphs would be put out of their sections. To understand the need, just think about translating texts that are properly listed alphabetically in english. Obviously they're not listed properly anymore after the translation.
How would you tackle the task ?
apart from the Toc, there 's no real hierarchy level in paraph styles, as far I know. Ther's no way, so far, to manipulate groups of mixed paraph.styles (except by using text frames… you see me coming^^).
Here's an example:
Before (meaning, after translation)
CCCC (Style: Title 1)
Title 3 level 2
text 5
text 6
BBBBB (Style: Title 1)
Title 2 level 2
text 3
text 4
AAAA (Style: Title 1 level 1)
Title 1 level 2
text 1
text 2
After sorting them properly:
AAAA (Style: Title 1 level 1)
Title 1 level 2
text 1
text 2
BBBBB (Style: Title 1)
Title 2 level 2
text 3
text 4
CCCC (Style: Title 1)
Title 3 level 2
text 5
text 6
Idealy, I would select my text blocks then run the script, very similar to sort-alpha scripts we use so far.
The first line of my selection would be in the style used for putting into order the texts
After thinking about it, I believe we could probably break down the task into smaller and simpler sub-scripts, like so :
1- Upon selection, detect groups of texts (starting from the 1st letter of Title 1 paraph.style, up to the next one - if any). Record position of 1st letter of selection.
- cut/ paste into new text frames the various group texts, as they are (meaning, keeping the current formatting)
2- - read the first letter of the text frames and sorting alpha the text frames
- Merge the frames
3- Copy/ paste the text from the merged text frame at the initial recorded position
- Delete text frame
What do you think ?
Copy link to clipboard
Copied
A good first project to sink your teeth into. Your algorithm seems to make a fair amount of sense on paper. You will learn a lot about moving paragraphs around and how to style them with this project; my main piece of advice: Work backwards through a given frame if you are removing paragraphs.
Copy link to clipboard
Copied
Hi guys,
Happilly, I managed to find a working solution, thanks to Peter Kahrel's awsome script "TableSort".
I'm now trying to create scripts to make a 3-steps sequence for a more versatile use (and to actually give really something useful to the community)
Basically, the process is :
- Select the mixed paragraphs I want to sort
- Use grep for adding a tab at the beggining of the first important paragraph lines (which have a specific Title style)
- Run TextToTable
- Remove the empty paragraph (End of cell - glyph "#") that I'm still trying to understand why the heck there're here and what would be the grep expression for removing them.
- Run P.Kahrel's TableSort.jsx (with keep formatting option on, obviously) (1 column/ tab option for both entries)
- Run TableToText to get back the wanted paragraphs
So far, it's not a 1-clic job, but it's working very fine, and quick enough.
Then, what now… another possible help (please) ?
Can anyone help me with :
- grep expression for removing the "space" at the end of a paraph, located at the very end of a cell (see image "end of cell")
Copy link to clipboard
Copied
Copy link to clipboard
Copied
For the sake of providing the answer to my own question 😛
Deleting empty bit at the end of the cell.
Select the table
Find: +\z
Leave blank the change part
Copy link to clipboard
Copied
Just giving an update on the project, in case someone is interested in juming in, or is just curious.
After being able to talk with our demi-god of us all (Peter Kahrel), who was very helpful and kind, I'm heading to provide 2 scripts.
- 1) A script using Conditionnal Text. The idea is to collapse the non relevelant text blocks, and only show the titles. After sorting the list in a traditionnal way (ID built-in script), we delete the Condition and recover our blocks.
- 2) Another script, that will automate the sorting with some options like, reverse sorting and swapping titles (For matters like sorting John_Doe vs Doe_John)
Stay tuned…
Copy link to clipboard
Copied
Hi guys,
Lots of things happened during the project, and Marc Autret luckily jumped in.
He revamped his previous script and gave us all a golden one.
Here it is:
https://www.indiscripts.com/post/2020/06/introducing-smart-sort-for-indesign-cc-cs
Despite the article being in french, the script is in english. You can jump at the bottom of the page and download the script ^^