What's New in IdExtenso 2.00601
June 14, 2020 | Tips | en | fr
IdExtenso has come a long way since its official launch three years ago. We presented the concept in Paris as part of an InDesign User Group session in May 2018. Since then, many tools and modules have been added to the framework, the most popular of which being JsxBlind 2.0, a pure JSXBIN obfuscator based on IdExtenso's bricks. Another famous example is the script Claquos 3, which of course is fully IdExtenso-driven:
Although our “ExtendScript Framework for InDesign Ninjas” obtains a relatively small audience in the InDesign scripting community, it steadily progresses on GitHub (as of today: 55 stars, 9 forks and up to 20 daily clones), showing that experienced JS/ExtendScript developers see the benefit of this project.
But let's not hide the truth: IdExtenso is not a calm and light environment. It is not easy to approach and requires solid skills if you wish to dig under the shell. Fortunately, you don't have to understand it to use it!
The core
brick weighs about 180 KB and allows you to get started with simple scripts. You don't even need to install IdExtenso structure on your hard disk since an “Includable JSXBIN image” is available as a JSX file. So, basically, you can start enjoying $$
by including one single file in your script.
ExtendScript Enhancements
IdExtenso's core package already supplies valuable features like $$.JSON
, $$.Log
, $$.Env
, etc. A little known fact is that it also provides fixes, patches, and improvements to ExtendScript itself. Here is a summary:
// [[global]] .parseInt() Patched (ExtendScript bug.) // String.prototype .lastIndexOf() Patched (CS4 bug.) .split() Patched (CS4 bug.) .toSource() Improved. .codePointAt() ECMAScript spec. ———— .toBase64() Converts into Base64. .toUTF8() Converts into UTF8. ———— .rpad() Right padding. .lpad() Left padding. ———— .trunc() Truncates. .ltrunc() Left truncation. .rtrunc() Right truncation. ———— .trim() Removes leading and trailing spaces. .ltrim() Left trim. .rtrim() Right trim. ———— .stripSpaces() Removes all spaces. .charSet() Set of characters of the string. // String (class) .fromCodePoint() ECMAScript spec. .fromBase64() Gets a string (UTF16) from Base64. .fromUTF8() Gets a string (UTF16) from UTF8. ———— .levenDist() Levenshtein dist. between 2 strings. .levenFilter() Applies levenDist to an array. ———— .random() Produces a random string. // Number.prototype .toSource() Variant of toString w/ extra options. .toHexa() Hexadecimal representation. .toDecimal() Variant of toFixed fixing rounding pbs. .toIEEE754() IEEE754 encoder (64bit) .toIEEE754_32() IEEE754 encoder (32bit) ———— .toAdbe() Adobe tag (0xHHHHHHHH -> 4 chars.) .isAdbe() Whether this number is an Adobe tag. // Number (class) .EPSILON As specified in ECMAScript 2015. .MAX_SAFE_INTEGER (idem) .MIN_SAFE_INTEGER (idem) .isInteger() (idem) .isSafeInteger() (idem) ———— .flatten() Prevents exponential representation. .parse() Enhanced parseFloat. .format() Formats a number into a string. ———— .fromIEEE754() IEEE754 decoder (64bit) .fromIEEE754_32() IEEE754 decoder (32bit) // RegExp.prototype .toSource() Valid, ASCII-safe, uneval string. .flags() Flag-string in g-i-m order. // RegExp (class) .escape() Cf github.com/benjamingr/RegExp.escape
Note. — For a much more detailed report of all IdExtenso additions, see the CHANGELOG.
Extra Modules
The /etc
branch is not included in the core package, but it contains many valuable add-ons that you can hardly do without in serious projects. I shall only focus on recent additions:
• $$.Collator is a simplified version of the Unicode Collation Algorithm (UCA). It allows you to sort strings according to a specific language and with respect to the UCA rules, all in ExtendScript! I'm specially proud of open-sourcing my code and sharing this utility after many years of work. $$.Collator replaces and supersedes an embryonic 2010 version which had nothing in common with the present implementation.
$$.Collator is designed to address LATIN, GREEK, CYRILLIC, ARABIC, HEBREW, ARMENIAN, BENGALI, DEVANAGARI, LAO, MALAYALAM, TAMIL, TELUGU, and THAI writing systems. It hosts specific tailoring rules for about 70 languages and then can sort words and strings in more than 200 languages in total. A demo script is available too.
• $$.Linguist is an essential module for addressing language and locale data. Its main component maps ISO639-1 codes with various extra information, so it can play the role of a database within other scripts or projects. For example, the meta-module $$.MetaCollator (which generates $$.Collator's resources) relies on $$.Linguist.
This module also encapsulates information on InDesign's LanguagesWithVendors
collection so it can translate localized language names into locale-independent strings, ISO keys, etc.
• $$.Unicode is an utility module added for dealing with Unicode data. So far, it manages Unicode blocks and keeps in memory the Adobe Glyph List—of primary importance for font-oriented scripts like IndyFont.
• $$.ByteStream, introduced in 2018 and still evolving, is a handy class for reading or writing a binary stream. I use it a lot in parsers that involve file formats like PNG, OTF, PSD or even InDesign resources. That's a great tool for hackers ;-)
• YALT is a localization module that fuels my scripts for a very long time. Available in IdExtenso from the very beginning, it now offers a default package with 300+ essential translation strings in FR, DE, SP, IT, RU. Most are inherited from InDesign's localized strings so they fit the conventions of the application.
Note. — The YALT()
function — aka __()
— has been improved in a way that sanitizes missing arguments. That is, if a YALT pattern specifies %i
placeholders while not supplying the corresponding args, then the undefined variables are automatically coerced into an empty string. For example, calling __("abc%1xyz")
without the %1
extra parameter will now return "abcxyz"
. (In the previous versions, "abcundefinedxyz"
would have been returned.)
• IdExtenso: github.com/indiscripts/IdExtenso
• Sample scripts (for newbies)
• Dev tools