-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[XML] add [sublime-snippet] syntax definition #576
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
143314a
[XML] add [sublime-snippet] syntax definition
keith-hall aeae14c
[XML] [sublime-snippet] support no cdata
keith-hall 8889887
[XML] [sublime-snippet] more tests to reflect accurate behavior
keith-hall b27aeb3
[XML] [sublime-snippet] don't show content in syntax list
keith-hall 9b96c3b
[XML] [sublime-snippet] allow easier navigation of snippets
keith-hall af5ed9b
[XML] [sublime-snippet] correctly detect when a closing brace is escaped
keith-hall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
%YAML 1.2 | ||
--- | ||
# See http://www.sublimetext.com/docs/3/syntax.html | ||
scope: text.sublime-snippet-content | ||
name: Sublime Text Snippet Content | ||
hidden: true | ||
contexts: | ||
main: | ||
- include: possible_caret | ||
|
||
possible_caret: | ||
- match: '\\[$}]' | ||
scope: constant.character.escape.sublime-snippet-content | ||
- match: '\$(?=\{|\w)' | ||
scope: meta.text-substitution.sublime-snippet-content keyword.other.caret.sublime-snippet-content | ||
push: caret | ||
- match: '\$' | ||
scope: invalid.illegal.unescaped-dollar.sublime-snippet-content | ||
|
||
caret: | ||
- match: '(?:(\d+(?!\w))|(PARAM\d+|SELECTION|TM_CURRENT_LINE|TM_CURRENT_WORD|TM_FILENAME|TM_FILEPATH|TM_FULLNAME|TM_LINE_INDEX|TM_LINE_NUMBER|TM_SELECTED_TEXT|TM_SOFT_TABS|TM_TAB_SIZE)\b)' # http://docs.sublimetext.info/en/latest/extensibility/snippets.html?highlight=snippet#environment-variables | ||
captures: | ||
1: constant.numeric.sublime-snippet-content | ||
2: constant.language.sublime-snippet-content | ||
pop: true | ||
- match: '\{' | ||
scope: keyword.other.caret.begin.sublime-snippet-content | ||
set: [inside_caret, caret] | ||
- match: '\w+' | ||
scope: meta.text-substitution.sublime-snippet-content constant.other.sublime-snippet-content #invalid.illegal.unknown-variable.sublime-snippet-content | ||
pop: true | ||
|
||
inside_caret: | ||
- meta_scope: meta.text-substitution.sublime-snippet-content | ||
- match: '\}' | ||
scope: keyword.other.caret.end.sublime-snippet-content | ||
pop: true | ||
- include: possible_caret | ||
- match: ':' | ||
scope: keyword.operator.alternation.sublime-snippet-content | ||
push: | ||
- meta_content_scope: string.unquoted.text-substitution.sublime-snippet-content | ||
- include: possible_caret | ||
- match: '(?=\})' | ||
pop: true | ||
- match: '/' | ||
scope: keyword.operator.regexp.begin.sublime-snippet-content | ||
push: | ||
- match: '/' | ||
scope: keyword.operator.regexp.end.sublime-snippet-content | ||
set: | ||
- match: '/' | ||
scope: keyword.operator.replacement.end.sublime-snippet-content | ||
set: | ||
- match: '[gims-]*' # x mode doesn't seem to work properly in snippets | ||
scope: storage.modifier.mode.regexp.sublime-snippet-content | ||
- match: '(?=\})' | ||
pop: true | ||
- match: '[^}]+' | ||
scope: invalid.illegal.unexpected-token.sublime-snippet-content | ||
- include: regex_replacement | ||
- include: scope:source.regexp#base-literal | ||
|
||
regex_replacement: # http://www.boost.org/doc/libs/1_56_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html | ||
- match: '\$\$' | ||
scope: constant.character.escape.regexp-replacement | ||
- match: '\$(\d+|\{\d+\}|&|\+(\{\w+\})?|^N)' | ||
scope: keyword.other.backref-and-recursion.regexp-replacement | ||
- match: \$(MATCH|PREMATCH|POSTMATCH|\{\^(MATCH|PREMATCH|POSTMATCH)\}|[`']|LAST_PAREN_MATCH|LAST_SUBMATCH_RESULT) | ||
scope: keyword.other.backref-and-recursion.regexp-replacement | ||
- match: '\\[1-9]' | ||
scope: keyword.other.backref-and-recursion.regexp-replacement | ||
- match: '\\[aefnrtv()]' | ||
scope: constant.character.escape.regexp-replacement | ||
- match: '\\[lLuUE]' | ||
scope: keyword.operator.case-conversion.regexp-replacement | ||
- match: '\)' | ||
scope: meta.literal.regexp-replacement | ||
- match: '\\x(\h{2}|\{\h{4}\})' | ||
scope: constant.character.escape.regexp-replacement | ||
- match: '\(\?([1-9]|\{\w+\})' | ||
scope: keyword.other.backref-and-recursion.conditional.regexp-replacement | ||
push: | ||
- meta_scope: meta.group.conditional.regexp-replacement | ||
- match: ':' | ||
scope: keyword.operator.alternation.regexp-replacement | ||
- match: '\)' | ||
scope: keyword.other.backref-and-recursion.conditional.regexp-replacement | ||
pop: true | ||
- include: regex_replacement | ||
- match: '\\\\' | ||
scope: constant.character.escape.regexp-replacement | ||
- match: '\\.' | ||
scope: constant.character.escape.regexp-replacement | ||
- match: '.' | ||
scope: meta.literal.regexp-replacement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
%YAML 1.2 | ||
--- | ||
# See http://www.sublimetext.com/docs/3/syntax.html | ||
file_extensions: | ||
- sublime-snippet | ||
name: Sublime Text Snippet (XML) | ||
scope: text.xml.sublime-snippet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that the
|
||
contexts: | ||
main: | ||
- match: '(<)(content)(>)' | ||
captures: | ||
1: meta.tag.xml punctuation.definition.tag.begin.xml | ||
2: meta.tag.xml entity.name.tag.localname.xml meta.toc-list.snippet-content.sublime-snippet | ||
3: meta.tag.xml punctuation.definition.tag.end.xml | ||
push: | ||
- match: '<!\[CDATA\[' | ||
scope: string.unquoted.cdata.xml punctuation.definition.string.begin.xml | ||
set: | ||
- meta_content_scope: string.unquoted.cdata.xml | ||
- match: '\]\]>' | ||
scope: string.unquoted.cdata.xml punctuation.definition.string.end.xml | ||
set: | ||
- match: '<!\[CDATA\[' | ||
set: | ||
- meta_scope: invalid.illegal.multiple-cdata-not-allowed.sublime-snippet-content | ||
- match: '\]\]>' | ||
pop: true | ||
- include: inside_content | ||
- include: snippet_content | ||
- match: '(?=\S)' | ||
set: inside_content | ||
- match: '(<)(scope)(>)' | ||
captures: | ||
1: meta.tag.xml punctuation.definition.tag.begin.xml | ||
2: meta.tag.xml entity.name.tag.localname.xml meta.toc-list.snippet-scope.sublime-snippet | ||
3: meta.tag.xml punctuation.definition.tag.end.xml | ||
- match: '(<)(tabTrigger)(>)' | ||
captures: | ||
1: meta.tag.xml punctuation.definition.tag.begin.xml | ||
2: meta.tag.xml entity.name.tag.localname.xml meta.toc-list.snippet-trigger.sublime-snippet | ||
3: meta.tag.xml punctuation.definition.tag.end.xml | ||
- include: scope:text.xml | ||
|
||
snippet_content: | ||
- include: scope:text.sublime-snippet-content | ||
|
||
inside_content: | ||
- match: '(</)(content)(>)' | ||
captures: | ||
1: meta.tag.xml punctuation.definition.tag.begin.xml | ||
2: meta.tag.xml entity.name.tag.localname.xml | ||
3: meta.tag.xml punctuation.definition.tag.end.xml | ||
pop: true | ||
- include: snippet_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"hidden_extensions": ["rss", "sublime-snippet", "vcproj", "tmLanguage", "tmTheme", "tmSnippet", "tmPreferences", "dae"] | ||
"hidden_extensions": ["rss", "vcproj", "tmLanguage", "tmTheme", "tmSnippet", "tmPreferences", "dae"] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that, if regex replacements in the find and replace panel supported the same functionality as snippets then this section would be better off in it's own syntax file in the Regular Expressions package. This would enable the regex replacement syntax to be used to syntax highlight the replace field in the find and replace dialog. also sublimehq/sublime_text#1079