How to get the Before and After hyphenation words in indesign scripting.
How to get AAA & BBBB and save in separate variables.
Please give idea.
@JesRoberts – you could test for the "lines.length" property of the word. If there is more than one line, the word is split. But that does not give you the parts (could be more than two). So you have to test for the lines index of every single character of the word.
i did something like this a while ago, but i can't find the code.
the problem is that the automated hypen does not apear in the text variable.
so.. (assuming that AAAABBBB is stored in myVariable)
myVariable.lines will get the line, ending with the first part of the word,and
myVariable.lines.. you get the ideea.
myVariable.lines.words[-1] will give you the entire word (AAAABBBB) so the trick i used was to insert a space at the end of the line like:
myVariable.lines.insertionPoints[-1].contents=" "; then get the first and last part of the word using
.lines.words[-1] and .lines.words then remove the added space (.lines.characters[-1].remove())
ps. it's just a guide to get you started, in the actual code you will have to be a bit more careful.
Use the below code to select the first part and second part seperately.
var myTxt = app.selection;
var myChar2 = app.selection.lines.characters;
alert("First part selected");
alert("Second part selected");
Europe, Middle East and Africa