iuyoy / highlight-string-code

Highlight string as specific language. 在其他代码中高亮 SQL、HTML、CSS或者JS
https://marketplace.visualstudio.com/items?itemName=iuyoy.highlight-string-code
MIT License
17 stars 4 forks source link

Problems with terminating SQL highlighter #21

Open Eccenux opened 4 months ago

Eccenux commented 4 months ago

Example code:

<?php
/**
    Query to be executed.
*/
$query = "
set search_path = '%SCHEMA%';

";

// test
function abc() {
    return "test";
}

Steps/problems

Normal PHP highlighting: obraz

Once I type in "SELECT" the string becomes unterminated and brakes whole file basically: obraz

Another example of broken highlighting because a comment happen to have "SELECT" in upper case: obraz

Another example where both SELECT and --being-sql is used. Notice how function is not highlighted: obraz

Expected

  1. I guess this auto-open, even in comments, is something some one would want, but it brakes my code. Would be great to be able to disable it in settings.
  2. Auto-open (with uppercase keywords) should only be triggered within strings (at least by default).
  3. String termination should terminate the highlighter (would also probably solve #19).
  4. If you want to support SQL in comments then comment termination should also terminate the highlighter. That should be optional.
  5. When --begin-sql is used auto-open should not be used.
RadoslawDeska commented 1 week ago

obraz

What you have is with hyphen, maybe that's why? I managed to solve this "highlighting is not terminating" problem by removing the hyphen. In this particular context I cannot use semicolon, so I cannot rely on caps-formatting.

In some scenarios you'd need a trailing semicolon. Then you can do: obraz

I'm using v0.4.5