Skip to content

Commit

Permalink
Initial version of HAML syntax mode. It's by no means finished yet, b…
Browse files Browse the repository at this point in the history
…ut it is usable. Currently multiline HTML comments don't work.
  • Loading branch information
gf3 committed Mar 6, 2009
0 parents commit 6f2e1aa
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
20 changes: 20 additions & 0 deletions Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>SEEMode.HAML Syntax</string>
<key>CFBundleName</key>
<string>HAML</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleGetInfoString</key>
<string>1.0, Copyright Author 2004</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
</dict>
</plist>
Empty file.
Binary file added Contents/Resources/English.lproj/InfoPlist.strings
Binary file not shown.
Binary file added Contents/Resources/English.lproj/Localizable.strings
Binary file not shown.
7 changes: 7 additions & 0 deletions Contents/Resources/ModeSettings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<template>mytemplate.txt</template> <!-- Provide a template for File->new -->
<recognition>
<extension casesensitive="yes">haml</extension> <!-- Add case sensitive file extensions -->
</recognition>
</settings>
65 changes: 65 additions & 0 deletions Contents/Resources/RegexSymbols.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<symbols>

<!--
The <symbol> tag specifies what is being shown in the fuction popup.
It features the following attributes, all optional if not noted otherwise:
id
Has to be a unique string. Has to be specified.
image
Specify an image includes in the application (no extension) or
specify an image in this modes Resources directory (with extension)
SubEthaEdit comes with the following images:
Symbol#, SymbolC, SymbolE, SymbolF, SymbolF(), SymbolG, SymbolK,
SymbolL, SymbolM, SymbolP, SymbolS, SymbolT, SymbolV, SymbolWarn
indentation
0-15 The level of indentation
font-weight
normal Normal font-weight (default)
bold Bold text in popup
font-style
normal Normal font-weight (default)
italic Bold text in popup
The example shows an symbol name "First example" with the image SymbolM
and an indentation of 1.
-->
<symbol id="First Example" image="SymbolM" indentation="1">

<!--
The regex tag specifies the regular expression that is search for this
symbol. It contains a Ruby-flavored regular expression. If groups is
specified in the regular expression the first group is used for the
find string. Escape unwanted groups with (?:).
This tag has to be specified.
Tip: Test your expressions with SubEthaEdits "Find All" command.
Tip: Case sensitivity can be set to ignore by including (?i) in your
expression.
-->

<regex>(function[^\n\r]*)</regex>

<!--
The postprocess tag specifies the find and replaces that should
be executed on the found string. You can use groups like \1 and the
like. It contains a Ruby-flavored regular expression.
This tag is optional.
The example search all strings enclosed by parens and replace them
with a empty string. Then it searches all occurances of "foo" and
replaces them with "bar".
-->

<postprocess>
<find>\([^\)]*\)</find>
<replace></replace>
<find>foo</find>
<replace>bar</replace>
</postprocess>
</symbol>

<symbol id="Second Example" font-weight="bold" image="SymbolF" indentation="0">
<regex>foobar</regex>
</symbol>

</symbols>
61 changes: 61 additions & 0 deletions Contents/Resources/SyntaxDefinition.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<syntax>
<head>
<name>HAML Syntax</name>

<autocompleteoptions use-spelling-dictionary="no" />

<charsintokens>
<![CDATA[_0987654321abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#%.]]>
</charsintokens>
</head>

<states>
<default id="Base" color="#000" inverted-color="#fff">
<state id="HTML Comment" color="#236E25" font-style="italic">
<begin><regex>/</regex></begin>
<end><regex>[\n\r]</regex></end>
</state>

<state id="Ruby Comment" color="#236E25" font-style="italic">
<begin><regex>-\s*#</regex></begin>
<end><regex>[\n\r]</regex></end>
</state>

<!-- Red #FE1A1A -->
<state id="HTML Element" color="#881280" inverted-color="#fac586" font-style="normal" font-weight="normal" useforautocomplete="no"> <!-- color="#d6771c" -->
<begin><regex>^\s*[^&amp;=-]{0,2}\s*[%\.#][\w_\.-]+</regex></begin>
<end><regex>[\n\r]</regex></end>
</state>

<state id="Ruby Symbol" color="#16A0B8" font-style="normal">
<begin><regex>(?:\:[\w_\.-?]+)</regex></begin>
<end><regex>[\n\r\s=]</regex></end>
</state>

<!-- From Ruby Mode -->
<state id="String with double quotes" type="string" color="#760f15" inverted-color="#f28720" font-style="italic" font-weight="normal" usespellchecking="yes">
<begin><regex>"</regex></begin>
<end><regex>(((?&lt;!\\)(\\\\)*)|^)"</regex></end>
<!-- (see line above) This is for the escape codes -->
<keywords id="test" color="#669999" inverted-color="#669999" font-style="normal" font-weight="normal" useforautocomplete="no">
<regex>(#\{[^{]*\})</regex>
<!-- regexp above *needs* the parens around the part to color change -->
</keywords>
</state>

<!-- From Ruby Mode -->
<state id="String with single quotes" type="string" color="#760f15" inverted-color="#f48700" font-style="italic" font-weight="normal" usespellchecking="yes">
<begin><regex>(?&lt;!\$)(?:')</regex></begin>
<end><regex>(((?&lt;!\\)(\\\\)*)|^)'</regex></end>
</state>

<state id="Inline Ruby" color="#000" usesymbolsfrommode="Ruby" useautocompletefrommode="Ruby">
<begin><regex>[&amp;=-]\s*[^#]</regex></begin>
<end><regex>[\n\r]</regex></end>

<import mode="Ruby" />
</state>
</default>
</states>
</syntax>
1 change: 1 addition & 0 deletions Contents/Resources/mytemplate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- # HAML Yays!
21 changes: 21 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
h1. HAML.mode

HAML.mode is a HAML syntax definition for SubEthaEdit/Coda. This is a work in progress so please be patient ;)

h2. Usage

h3. Installation

Simply check out this repo into either *<code>~/Library/Application Support/Coda/Modes</code>* or *<code>~/Library/Application Support/SubEthaEdit/Modes</code>*, be sure to name the directory *<code>HAML.mode</code>*.

h2. Known Issues

* Currently the syntax highlighting for multiline HTML comments is not working.

h2. Author

Written by Gianni Chiappetta - "Runlevel6":http://www.runlevel6.org/

h3. Credits

Thanks to "Panic":http://www.panic.com/ for creating a kick-ass editor!

0 comments on commit 6f2e1aa

Please sign in to comment.