Smultron syntax colours your document if you have chosen so with the syntax definition of your choice.
(<?php and everything in grey until the closing tag (not shown here) are Instructions. <head><title> are Commands. echo is a keyword.)
The keys are: (I use php as an example within parentheses):
excludeFromKeywordStartCharacterSet
excludeFromKeywordEndCharacterSet
includeInKeywordStartCharacterSet
includeInKeywordEndCharacterSet
just add all characters you want, to the string to these keys.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<array>
<plist version="1.0"><dict>
<key>name</key>
<string>PHP</string>
<key>file</key>
<string>php</string>
<key>extensions</key>
<array>
<string>php php3 phtml phtm</string>
</dict>
</plist>
The name-key is what shows up in the View menu and the file-key is what you name your file minus the .plist extension. The extensions-key lists the various extensions your language can have, space separated and without dots.
The colours:
The easiest way to learn which colours to choose in Preferences is to test on a document which you know well. But below is an image of a fictional php-code which might help you.
(<?php and everything in grey until the closing tag (not shown here) are Instructions. <head><title> are Commands. echo is a keyword.)
Change a syntax definition:
The syntax definitions are defined in plist files in the Application bundle (ctrl-click on Smultron and choose Show Package Contents -> Contents -> Resources) e.g. html.plist for HTML documents. If you want to change anything or add a keyword you can just change the file and save it. (Remember to treat special characters in the standard xml-way e.g. < instead of < and if you don't want leave a string empty please do it like this <string></string>.)The keys are: (I use php as an example within parentheses):
beginCommand:
(<) to show html commandsendCommand:
(>)beginInstruction:
(<?) to start a block of codeendInstruction:
(?>)beginVariable:
($) the character (or any of the characters) that signals that it is a variableendVariable:
(:;(){}=[]+-/.,*!?%&><\) anyone of these characters ends the variable namefirstString:
(") only one character is recognised for the stringssecondString:
(')firstSingleLineComment:
(//) a comment till the end of the linesecondSingleLineComment:
(#) another comment till the end of the linebeginFirstMultiLineComment:
(/*) the start of a multiline commentendFirstMultiLineComment:
(*/)beginSecondMultiLineComment:
(<!--) to allow e.g. html comments in php-codeendSecondMultiLineComment:
(-->)keywordsCaseSensitive:
(<false/>) set either to </false> or </true> if you want the keywords to be case sensitiverecolourKeywordIfAlreadyColoured:
(<false/>) if you want a keyword to be coloured as a keyword even if its already been coloured as a commandkeywords:
(<string>and</string>) a list of keywordsautocompleteWords:
(<string>auto-complete this word</string>) a list of words to add to the auto-completionfunctionDefinition:
(<string>a regular expression</string>) a regular expression that finds the beginnings of functions in the documentremoveFromFunction:
(<string>a string</string>) a string that is removed from the function name, e.g. if the function is defined by having the word function in front of it, it can be removed from the list to make it easier to readattributes:
you cannot define this yourself but it defined as the word before a = in a commandOptional values
You can also add any of four optional strings which adds or removes characters from the character sets that decide where a keyword can start or end. The four keys are:excludeFromKeywordStartCharacterSet
excludeFromKeywordEndCharacterSet
includeInKeywordStartCharacterSet
includeInKeywordEndCharacterSet
just add all characters you want, to the string to these keys.
Add new definition:
If you want to add a new definition, you must create a new file named languagename.plist and fill it with information as per above (it is easiest to copy an a plist file and only change what you need). Then you add a (or open the existing) SyntaxDefinitions.plist file in the /Users/<your home folder>/Library/Application Support/Smultron folder and add a dictionary into the file. The best way to do this is to make a copy of the SyntaxDefinitions.plist that's in the application bundle and start from that one. An example is below:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<array>
<plist version="1.0"><dict>
<key>name</key>
<string>PHP</string>
<key>file</key>
<string>php</string>
<key>extensions</key>
<array>
<string>php php3 phtml phtm</string>
</dict>
</plist>
The name-key is what shows up in the View menu and the file-key is what you name your file minus the .plist extension. The extensions-key lists the various extensions your language can have, space separated and without dots.