-
Notifications
You must be signed in to change notification settings - Fork 586
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
Conversation
...which will highlight as XML initially, until the content is reached, whereby it will also highlight (nested) placeholders and their optional regular expression replacements
Note that the syntax test file deliberately doesn't have a |
Maybe it would make sense to suggest a fixed syntax test file extension to Jon and Will? |
- 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 |
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
I get by with the following tiny plugin, which, when a syntax_test file is opened, will set the syntax to the one specified in the syntax test header line - maybe it could be added to the Default package that ships with ST3:
|
XML/Snippet.sublime-syntax
Outdated
scope: text.xml.sublime-snippet | ||
contexts: | ||
main: | ||
- match: '(<)(content)(>)(<!\[CDATA\[)' |
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.
The <![CDATA[
part may be provided on the next line (or even be skipped entirely) afaik.
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.
@FichteFoll thanks for the heads up - I've done some testing and you are correct. Also, if more than one CDATA section is used, ST ignores any but the first, so I've marked any others as illegal.
Linking a few reference implementation of snippet syntaxes (which you probably checked already): |
By the way, I'd like to use this for the next PackageDev update, unless Jon decides he wants special highlighting for ST's internal configuration to ship by default – if I may. Related: #95 |
...but it can still be set manually by a plugin etc.
I think this probably makes sense to add. I will check it out further and try it on my machine. From a quick glance at the code, I am wondering if a suffix of |
If it makes sense to add this, does that mean that syntax definitions for other resource files should be added as well (thinking about sublime-syntax, sublime-keymap, sublime-commands, sublime-mousemap, sublime-menu, sublime-project) ...? See also #95 (comment). |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the new_snippet
command in Packages/Default/new_templates.py
currently references the normal XML syntax, and this should be changed in the ST3 codebase after merging.
v.assign_syntax('Packages/XML/XML.sublime-syntax')
@wbond there are currently 2 syntax definitions included in this PR, one for the snippet XML and one for the |
In packagedev we use raw-snippet iirc. |
Did you ever try this out @wbond ? :) The main reason why I'd like this definition added is because a lot of people put an unescaped |
I haven't yet - been primarily working on non-package stuff recently. |
Based on the decision in #95, I think I am going to decide to not include this for now. My understanding is that https://packagecontrol.io/packages/PackageDev is the goto package to include augmented syntaxes and helpers. I think that makes sense for the time being. We may revisit this in the future and decide that including syntaxes and helpers for the built in formats makes sense. For now, users can use the default XML syntax, or install something like Package Dev. |
...which will highlight as plain XML initially, until the content is reached, whereby it will also highlight (nested) placeholders and their optional regular expression replacements