-
-
Save kmplngj/2f5a447d92f4f761f0ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var root = app.activeDocument; | |
var result = getStyleByString(root, "Formatgruppe 2:Form\\:atgruppe 1:Zeichen\\:\\:format 1", "characterStyles"); | |
$.bp(); | |
function getStyleByString(root, string, property) { | |
stringResult = string.match (/^(.*?[^\\]):(.*)$/); | |
var cStyleName = (stringResult) ? stringResult[1] : string; | |
cStyleName = cStyleName.replace (/\\:/g, ":"); | |
remainingString = (stringResult) ? stringResult[2] : ""; | |
var newProperty = (stringResult) ? property.replace(/s$/, '') + "Groups" : property; | |
var cStyle = root[newProperty].itemByName(cStyleName); | |
if (remainingString.length > 0 && cStyle.isValid) cStyle = getStyleByString (cStyle, remainingString, property); | |
return cStyle; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment