Word Wrap Using Python on Source Credits?

Discussion created by GISGlobe on Sep 30, 2013
Latest reply on Oct 1, 2013 by msayler
Wondering if there is a way to word wrap the output from the following, assuming I am trying to fit it into a small area and will  like decide how many words per line.  The code and a sample output are attached for your convenience.


<dyn type="document" property="service layer credits" separator="\n" showLayerNames="false" layerNameSeparator=": "/>

Sample Output:
World_Imagery - Source: Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community

Final goal is to be able to stack/wrap at every 4 or 5 words.  Thanks for the help.

FYI: I have tried implanting "\n" at several intervals with no luck.