Reputation: 51
I'm a bit of a noob when it comes to Sublime Text 2 having recently switched from KomodoEdit. I'm trying to setup syntax highlighting for a template string that gets embedded into a JSON request. Here are a couple example lines:
{
"shipment_number": "{%% prop : parent-clip : SHIPMENT_NUMBER %%}",
"product_code": {%% prop : parent-clip : PCNum %%}
}
the part I want highlight is the {%% property-type : path-type : property-path %%}
part and highlight the {%% and the 3 text pieces individually. So I've read a lot of stuff on Sublime and Textmate and many example git but I'm still not grocking this stuff. Could someone point me in the right direction? here is what put together so far
{ "name": "JSON+CloudTest ISSE",
"scopeName": "source.isse",
"fileTypes": ["json"],
"patterns": [
{ "name": "keyword.tag.isse",
"comment": "based on example at http://gerd.knops.org/?p=9",
"include" : "source.json",
"begin": "{%%",
"match": "\\b([^:]+)\\b",
"captures" : {
"1" : {"name" : "storage.type.isse"},
"2" : {"name" : "storage.modifier.isse"},
"3" : {"name" : "storage.type.variable.isse"}
},
"end": "%%}",
],
"uuid": "4e9dce7e-287e-4ec0-b13f-bfed23b44982"
}
when I try to build this the tmlanguage file is a zero byte file. why?
Thanks in advance.
Upvotes: 0
Views: 205
Reputation: 19754
You have mismatched curly braces (there should be a curly brace after "end": "%%}",
though the comma should be removed first). I fixed it and ran it through a json to plist converter.
<?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>fileTypes</key>
<array>
<string>json</string>
</array>
<key>name</key>
<string>JSON+CloudTest ISSE</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>{%%</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.type.isse</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.modifier.isse</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>storage.type.variable.isse</string>
</dict>
</dict>
<key>comment</key>
<string>based on example at http://gerd.knops.org/?p=9</string>
<key>end</key>
<string>%%}</string>
<key>include</key>
<string>source.json</string>
<key>match</key>
<string>\b([^:]+)\b</string>
<key>name</key>
<string>keyword.tag.isse</string>
</dict>
</array>
<key>scopeName</key>
<string>source.isse</string>
<key>uuid</key>
<string>4e9dce7e-287e-4ec0-b13f-bfed23b44982</string>
</dict>
</plist>
Upvotes: 1