Copy link to clipboard
Copied
Looks like a bug to me?
Words collection for a Story - or Paragraph - that has ONLY Tables - is empty...
Copy link to clipboard
Copied
Well, depends on how you look at it. From InDesign's perspective it's consistent. A table sits in a placeholder that's dubbed Character, but it's not a character in the sense of a glyph. When you (grep) search . (any character( you won't find anything.
The same goes for embedded frames, you get the same results.
Copy link to clipboard
Copied
But "it occupies some space" in the collection of characters? And even one letter words are words?
Copy link to clipboard
Copied
Conceptually a word is not a "building block" in the same way that character is. If I was writing a word-parser I probably would opt to to treat non-glyph characters as word boundary markers, ie. not part of a word. So my parser would return zero too.
- Mark
Copy link to clipboard
Copied
Hi @Robert at ID-Tasker , Look at table properties—there is the storyOffset, which is the insertionPoint I think @Peter Kahrel is referring to.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Table.html
Copy link to clipboard
Copied
Yes, I know.
But you can't use StoryOffset to get a reference of the Table - even when documentation says that InsertionPoint has a Tables collection - it return "0": (*)
So you would need to get Index of the InsertionPoint then get a reference to the Character in the same Story - then you can get the Table.
And myTable.parent returns TextFrame... which is crazy on its own...
But if you add a letter(s) before and after - then you get a Word:
(*) don't have time to check, but I'm pretty sure, all other collections also will be empty - someone just based InsertionPoint on the Text:
Copy link to clipboard
Copied
But that's nothing - I've just finished adding some math functions:
So now it's possible to reformat values - in tables or in text - and then re-calculate and update totals.
Copy link to clipboard
Copied
Words collection for a Story - or Paragraph - that has ONLY Tables - is empty...
The word collection for a story with multiple returns or white spaces also empty.
var i = app.activeDocument.stories.everyItem().insertionPoints.everyItem().getElements();
$.writeln(i.length)
//returns 15
var w = app.activeDocument.stories.everyItem().words.everyItem().getElements();
$.writeln(w.length)
//returns 0
Copy link to clipboard
Copied