Skip to content

Multi Highlighter ​

TSynMultiSyn (unit SynEdit.Highlighter.Multi) combines several highlighters in the same document, for example HTML with embedded CSS and JavaScript, or Pascal with SQL inside the strings.

How it works ​

The component has a default highlighter for the text outside the schemes, and a collection of schemes. A scheme is a region of the text, that starts with a given expression, ends with another one and is highlighted with its own highlighter.

Property of TSynMultiSynDescription
SchemesThe collection of the schemes.
DefaultHighlighterThe highlighter of the text outside the schemes.
DefaultLanguageNameThe language name of the whole combination.
OnCustomRangeEvent to extend the ranges computed by the highlighters.
Property of a scheme (TScheme)Description
StartExprRegular expression that starts the scheme.
EndExprRegular expression that ends the scheme.
HighlighterThe highlighter used inside the scheme.
CaseSensitiveCase sensitive matching of the expressions.
MarkerAttriThe attributes of the start and end markers.
SchemeNameThe name of the scheme.
OnCheckStartMarker, OnCheckEndMarkerEvents to decide in code whether a marker is valid.

Example ​

HTML pages with scripts:

  1. Drop a TSynMultiSyn, a TSynHTMLSyn and a TSynJScriptSyn.
  2. Set DefaultHighlighter to the HTML highlighter.
  3. Add a scheme with StartExpr = <script[^>]*>, EndExpr = </script> and Highlighter = the JavaScript highlighter.
  4. Assign the TSynMultiSyn to the Highlighter property of the editor.

The same technique allows the links of the comments to be recognized, combining a language with TSynURISyn for TSynURIOpener.

Released under the MPL 1.1 / GPL 2 dual license.