Open emeraldtip opened 1 year ago
This is a nice project for you to collaborate if you're interested. You won't need to compile anything, just implementing the syntax definition file that can be tested locally, since definitions can be extended with JSON files, similar to what you shared. Here's is more information on how to do it. If you implement the JSON file I'll just convert it to C++ and add it as default language (the C++ conversion is automatic, ecode provides some command line utilities). You'll need mostly to convert the RegEx patterns to LUA Patterns. I currently don't support RegEx patterns basically because they are usually much slower, but I need to find a proper solution by using some of the fastest RegEx libraries, though I haven't found any good reason to do it for the moment.
Aight, will do once I have time
So the comment section in the language config for automatic comment functionality, you need to set a comment string But handlebars uses a start and end sequence for comments:
{{! This comment will not show up in the output}}
Should I just add the comment start sequence there?
I'm not sure if I understand the question, but for comments we use this format:
{ "pattern": ["lua_pattern_start", "lua_pattern_end", "escape_character"], "type": "type_name" }
so for your example should be:
{ "pattern": ["{{!", "}}", "\\"], "type": "comment" }
(I assume they support an escape characeter, otherwise the third element in the array "\" should be removed)
so for your example should be:
{ "pattern": ["{{!", "}}", "\\"], "type": "comment" }
Thanks!
What about this though:
"comment": "Sets the comment string used for auto-comment functionality."
Should it be:
"comment": "{!-- --}"
or
"comment": "{!--"
All of these are the same, for ranged comments
{{! This comment will not show up in the output}}
<!-- This comment will show up as HTML-comment -->
{{!-- This comment may contain mustaches like }} --}}
you need to basically define the opening pattern and the closing pattern:
{ "pattern": ["{{!--", "--}}", "\\"], "type": "comment" },
{ "pattern": ["{{!", "}}", "\\"], "type": "comment" },
{ "pattern": ["<!%-%-", "%-%->", "\\"], "type": "comment" },
The order definition of the patterns does matter because it's the order that it's used to evaluate each pattern to the document text.
Maybe it would be a good idea to study any of the current languages definitions available to see how they work. For handlebars you could use HTML or XML definition as a base. Take this as an exercise, if you find it too difficult just leave it and I'll take a look later.
I understand how those patterns work, im talking about this section:
What should I add there?
Keep it empty for the moment (""). That's for single line comments to be applied in a range selection with CTRL+/
How does one have one scripting language inside another - so for example how did you do the JS highlighting inside HTML script tags?
Oh sorry, I missed this question. It's usually super easy, but depends on the case, if you can detect from a pattern the start of a new language and the end of it, you just need to add it as any other ranged pattern:
For example, CSS inside an HTML, looks for
{
"pattern": [
"<%s*[sS][tT][yY][lL][eE][^>]*>",
"<%s*/%s*[sS][tT][yY][lL][eE]%s*>"
],
"syntax": "CSS",
"type": "function"
}
Thy only difference is that you specify the language with the "syntax" property.
I will get to work on this soon, I've been procrastinating and doing other things as I was too lazy to learn lua patterns, but I should have some time on my hands now, so hopefully it'll be done sooner rather than later.
Handlebars is a semantic template something something language for web development. Pretty much HTML but with added spice.
I think this should be the correct file thing for the highlighting things????????