haml syntax display

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
chender33
Posts: 4
Joined: Sun Jan 03, 2010 5:41 pm

haml syntax display

Post by chender33 »

I recently switched to windows 7 (from linux) and discovered textpad for editing. Functionality is terrific, but I need to be able to recognise haml.

I have exhausted searches in google, and no mention here in the Textpad forums. I have ruby installed, and gem haml installed too. Google searches direct me to stuff about installing an IDE and I don't want that degree of set up - I want to use Textpad which meets all my other needs.

Can anyone direct me to how to set up haml and recognise haml syntax in TextPad?

Many thanks in advance.
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

You just need to edit another syntax file and save it with a new name for haml syntax. Seach this forum for posts on "create syntax", include BOTH words.

Also see the TextPad HELP section on "Syntax Definition Files".

Once the syntax file is created, you need to associate that syntax file with the haml Class that you should also create.

You can also upload the syntax file to this site so that others can also use it.
Hope this was helpful.............good luck,
Bob
chender33
Posts: 4
Joined: Sun Jan 03, 2010 5:41 pm

Post by chender33 »

Bob ... I get the concept, but I do not know how to create a haml syntax file. Thats what I need.
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

From my first response:
You just need to edit another syntax file and save it with a new name for haml syntax.
What do you not understand?
1. Open an existing syntax file in TextPad.
2. Edit it to reflect the needs of the haml file, use the TextPad HELP.
3. Save the edited file as haml.syn.
4. Create a Class for haml
5. Assign the haml.syn file to the haml Class definition options.
Hope this was helpful.............good luck,
Bob
chender33
Posts: 4
Joined: Sun Jan 03, 2010 5:41 pm

Post by chender33 »

I should have been more clear:

The part I am not qualified to do is 2:

2. Edit it to reflect the needs of the haml file
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

From the TextPad HELP file:
--------------------------------------
Syntax Definition Files
Syntax definition files contain the information TextPad uses to highlight keywords in different colors. A standard set is provided for common programming languages, and contributed files are available from the TextPad web site.

If you want to implement syntax highlighting for a document class that has not been catered for, you must create a file of keywords that you want to be colored, as described below, and save it as "myfile.SYN" in the Syntax folder. Note that double byte character sets cannot be used in syntax definition files.

The first line of the file must be one of the following:

TEXT=1 means that only URLs will be highlighted. All sections of the syntax definition file are ignored, so do not use this type.
C=1 means that full syntax highlighting is available for languages which broadly conform to C syntax. All keywords are in a single namespace, so duplicates are not allowed.
HTML=1 means that full syntax highlighting is available for languages which broadly conform to HTML syntax. Keywords are in two namespaces, with tags in one and their attributes in the other. The Namespace1 parameter controls how many of the six [Keyword] sections are in the first namespace. Having two namespaces allows keywords such as TITLE, which can be both a tag and an attribute, to be colored according to context.
PERL=1 is a variant of C=1, to take account of some peculiarities of Perl syntax.
LaTeX=1 is a variant of C=1, to take account of some peculiarities of LaTeX syntax.
We will introduce other grammars as and when necessary.

The rest looks like an .INI file, with the following sections:

[Syntax]
[Keywords 1]
[Keywords 2]
[Keywords 3]
[Keywords 4]
[Keywords 5]
[Keywords 6]
[Preprocessor keywords]
The [Syntax] section must be first, followed by [Keywords 1]. The other sections are optional. The [Preprocessor keywords] section can only be used when a single character (such as "#") is used to start a statement that is handled by a pre-processor.

Keywords are entered one per line. The split between the keyword sections is arbitrary. You only need to use Keywords 2-6, if you want some keywords in different colors. They are all in the same namespace, unless "HTML=1" is used, when "Namespace1 = n" specifies how many of the keyword sections are in the first namespace, with the remainder in another. This means that the same name can appear in both namespaces when "HTML=1". The pre-processor keywords are always in their own namespace.

You can select the newly created .SYN file using the Preferences command on the Configure menu. It should be displayed in the drop-down list box for Syntax settings, for the new document class you created.

The [Syntax] section must contain the following lines:
Namespace1 = a number in the range 1 to 6, which specifies how many of the keyword sections are in the first namespace. There is only one namespace when "C=1" or "LaTeX=1", so this value must be 6. There are two namespaces when "HTML=1", so this value can be between 1 and 5, and defaults to 1. Change it to 2, say, if you want to be able to display HTML tags in two colors, and split the tag keywords between the [Keywords 1] and [Keywords 2] sections, depending on which color you want them in.
IgnoreCase = "Yes" if keywords are not case sensitive, otherwise "No".
KeyWordLength = the number of characters in each keyword. If this entry is omitted, or set to 0, keywords can be of variable length. It is only required for fixed length keywords that run together, without any delimiters.
BracketChars = characters that can be used for brackets.
OperatorChars = characters that can be used for operators.
PreprocStart = the character used to start a pre-processor statement.
HexPrefix = the characters that prefix hexadecimal numbers. If this entry is omitted, it defaults to "0x".
SyntaxStart = a string of characters that switch on keyword recognition (e.g. "<"), or leave blank.
SyntaxEnd = a string of characters that switch off keyword recognition (e.g. ">"), or leave blank.
CommentStart = a string of characters that start a multiple line comment, or leave blank.
CommentEnd = a string of characters that end a multiple line comment, or leave blank.
CommentStartAlt = an alternative string of characters that start a multiple line comment.
CommentEndAlt = an alternative string of characters that end a multiple line comment.
SingleComment = a string of characters that start a single line comment (e.g. "//" or "REM"), or leave blank.
SingleCommentCol = If a single line comment must start in a specific column, assign the number here. If it must start in the first non-blank column, assign "Leading" here.
SingleCommentAlt = an alternative string of characters that start a single line comment (e.g. "//" or "REM"), or leave blank.
SingleCommentColAlt = If the alternative single line comment must start in a specific column, assign the number here. If it must start in the first non-blank column, assign "Leading" here.
SingleCommentEsc = The character that is used to escape either of the SingleComment strings.
StringsSpanLines = "Yes" if strings can continue over line boundaries, otherwise "No". This can be used in conjunction with StringEsc, if the string can only be continued when the new line is escaped with that character.
StringStart = The character that indicates the start of a string (e.g. double quote).
StringEnd = The character that indicates the end of a string (e.g. double quote).
StringAlt = An alternative character that can be used to delimit strings, if the string contains the StringEnd character.
StringEsc = The character that is used to escape the StringEnd character, if it is part of a string (e.g. "\").
CharStart = The character that is used to start a character literal (e.g. single quote).
CharEnd = The character that is used to end a character literal (e.g. single quote).
CharEsc = The character that is used to escape the CharEnd character, if it is part of a character literal (e.g. "\").
----------------------------------
Hope this was helpful.............good luck,
Bob
chender33
Posts: 4
Joined: Sun Jan 03, 2010 5:41 pm

Post by chender33 »

Thank you Bob ... I really appreciate what you are laying out for me here, so I am going to go off and study this and see what I can do.
Post Reply