对于最近从KomodoEdit切换的Sublime Text 2,我有点像菜鸟。 我正在尝试为嵌入到JSON请求中的模板字符串设置语法突出显示。以下是几个示例行:
{
"shipment_number": "{%% prop : parent-clip : SHIPMENT_NUMBER %%}",
"product_code": {%% prop : parent-clip : PCNum %%}
}
我要突出显示的部分是{%% property-type : path-type : property-path %%}
部分,并分别突出显示{%%和3个文本部分。所以我在Sublime和Textmate以及许多示例git上阅读了很多东西,但我仍然没有讨厌这些东西。有人能指出我正确的方向吗?这是迄今为止汇总的内容
{ "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"
}
当我尝试构建它时,tmlanguage文件是一个零字节文件。为什么呢?
提前致谢。
答案 0 :(得分:1)
你有不匹配的花括号("end": "%%}",
之后应该有一个大括号,虽然应该首先删除逗号)。我修好了它并通过json转换为plist转换器。
<?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>