Skip to content

Serialized Conversion

FichteFoll edited this page Mar 12, 2022 · 1 revision

As described in the Background section of legacy syntax definitions, TextMate used the Property List format for all of its resource files. Because hand-editing XML is annoying, functionality for converting between Property Lists, JSON and YAML has been added to PackageDev.

The functionality was primarily intended for syntax definitions, but it can be used for color schemes and TextMate Preferences files alike. Even JSON files like menus can be converted to or from YAML.

Build System: Convert to …

The "Convert to..." build system can interchangably convert JSON, YAML and Property List files. The source format is automatically detected where possible, and you will then be prompted for the target file's format.

By default, the target file's extension is determined by the following rules:

  • I am json.json is converted into I am json.plist or .yaml, depending on the target format.
  • I am json.JSON-propertyList (or .YAML-propertyList) is converted into I am json.propertyList regardless of the target format.

Overriding Target Format And Extension

Both, the target format and the extension, can be configured on a per-file basis by an options comment in the first three lines (usually the first, except for XML-based Property Lists).

An options comment consists of

  1. a comment start marker,
  2. the sequence [PackageDev] followed by whitespace
  3. a YAML flow mapping without surrounding curly braces ({})
  4. a comment end marker (optional).

Currently supported options (keys) are:

  • target_format - expected values: plist, yaml or json
  • ext - the target extension without leading .

Example (YAML):

# [PackageDev] target_format: plist, ext: tmLanguage

Example (JSON):

// [PackageDev] target_format: plist, ext: tmLanguage