I have just released my first Nova syntax extension for Handlebars, which is a templating extension for HTML. The syntax is now detected in HTML files using the following combo selector:
This works in all HTML files containing a Handlebars typical string {{…}}, but in files starting with <!DOCTYPE html> the detector fails and the syntax highlighting stays on HTML.
Is there something wrong with the detector or is there a way to override the default HTML detection?
Hmm. I just loaded your extension, and it seems to be working properly for me.
I created a document with the following content:
<!DOCTYPE html>
{{ testing }}
Opening this file correctly chooses the “Handlebars” language.
If perhaps there’s something more file-specific going on, would you mind providing a file you’re seeing this behavior in, and I can continue investigating! Otherwise, I guess my first suggestion would be to perhaps check that you don’t have any user-level overrides in your Nova Preferences → Files → Custom File Types that might force these files to HTML or something similar?
@logan Thank you for testing and finding out, that the Doctype string is not the problem. I have checked my preferences and there are no rules defined either for Handlebars or HTMl files.
I have now run some more tests and now it is getting weird. A file with the following content is not detected as Handlebars:
If I remove a random line from it, it shows up as Handlebars – even a blank line. I have stripped the structure down to a minimum that is not detected as Handlebars (the two blank lines at the top are mandatory):
I think I’ve found the issue. Nova’s match-content syntax detector type has a default line count (of 10 lines) enforced if you don’t specify one yourself, a fact that I’ve entirely overlooked. These are documented to be unbounded by default, and you might be the first person for whom we’ve now discovered this.
I’ll make sure this gets amended in the implementation for our next major release to be truly unbounded, but in the interim, if you add a lines attribute, such as <match-content lines="10000"> (or set to a similar high-bound), it should hopefully get things working?