comet.strutils¶
The comet.strutils module provides comet specific string manipulation functionality.
For common string operations use the default Python str
functionality.
Methods¶
- comet.strutils.getNetweight(source: str, convertUniTags: bool = False, replaceTypos: bool = False) str ¶
Determine the net value of a string. The net values of the strings are calculated as follows:
Empty strings are replaced by an invisible space (Unicode 0x200B).
UTF-8 characters are uniformly translated into <0xXXXX> tags.
If the text begins with %!TT, the ParaStyle tag immediately following it (if present) is removed.
All other ParaStyles are replaced by paragraph separators.
All <nl:> are replaced by paragraph separators.
All other TaggedText tags are removed from the text.
All double quotation marks are replaced by “ and all single quotation marks by ‘.
All types of spaces (Unicode 0x2000 - 0x200F) are replaced by blanks.
All types of separators (Unicode 0x2010 - 0x2016) are each replaced by a minus sign.
- Parameters:
- Returns:
The netweight version of parameter source
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- Examples:
Convert german Umlauts to uniform tags and show them in a dialog.
- comet.strutils.escapeTagged(source: str) str ¶
Replace all non-ASCII characters with TaggedText markers.
- Returns:
The version of parameter source where non-ASCII characters have been replaced.
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- comet.strutils.unescapeTagged(source: str) str ¶
Replace TaggedText markers with the corresponding UTF8 characters.
- Returns:
The version of parameter source where TaggedText markers have been replaced.
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript: