This is documentation for as yet unreleased features and is subject to change. Custom syntax definitions are not currently available in Drafts, but will be coming later this year. This documentation is provided to request feedback from parties interested in creating custom syntax definitions.
Syntax definitions are the configurations that power syntax highlighting in Drafts. For each syntax you can select and assign to a draft, there is a syntax definition that contains the regular expressions used to analyze and assign
scopes to characters and strings in your text. The
scopes are used in combination with theme files to assign attributes to the text, such as font weights, size, colors, etc.
Syntax definitions do not directly define the styles for text, only the scope to use when styling text, so must be combined with themes to fully render the text.
Drafts syntax definition format is designed to be relatively simple and serve the needs of a notes-focused app. Although syntax definitions for programming languages can be created, so not expect this format to compete with dedicated code editors. It’s goals are more focused on allowing custom markup, navigation, and tasks.
Drafts ships with built-in syntax definitions for Markdown and a number of other formats. If you use a markup format not covered by these, you might find it useful to create or install additional custom syntax definitions. Perhaps, you have certain keywords you would like to highlight in your text. Or a special way you would like to be able to navigate within your drafts.
If you are interested in creating your own syntax definitions, continue on to the Creating Syntaxes article. To find ready-to-use syntaxes, visit the Drafts Directory, where additional syntaxes created by the community can be found and installed.
Syntaxes are stored in your Drafts data, and sync between devices along with other data. Once installed, a custom syntax is available to be selected and assigned to drafts, or even used as your default for new drafts. For general information about selecting and using syntaxes, see the Syntax Highlighting article.