Skip to content

Instantly share code, notes, and snippets.

@indiscripts
Created June 12, 2019 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indiscripts/cf5c1fb006f0954fbed6575cd5e40cd7 to your computer and use it in GitHub Desktop.
Save indiscripts/cf5c1fb006f0954fbed6575cd5e40cd7 to your computer and use it in GitHub Desktop.
Flatten Nested Styles
(function(a,e,g,c,b,n,j,i,t)
{
for(a=a.stories[e='everyItem']()[g='getElements']();s=a.pop();)if((c=s.characters).length)
{
for(j=i=(b=c[e]().appliedNestedStyles).length;0<=i--;
(n===(t=(b.pop()||0)[0]))||((n&&(c.itemByRange(1+i,j).appliedCharacterStyle=n)),j=i,n=t));
for(b=s.paragraphs[e]().nestedStyles[e]()[g]();t=b.pop();
t.isValid&&t.remove());
}
})(app.activeDocument);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment