TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Highlighting Parts of Lua as Bash

22 点作者 xnacly4 个月前

1 comment

mdaniel4 个月前
An alternative approach is to use comments, which allow changing <i>arbitrary</i> string literals into injected contexts, as JetBrains does: <a href="https:&#x2F;&#x2F;www.jetbrains.com&#x2F;help&#x2F;idea&#x2F;using-language-injections.html#use-language-injection-comments" rel="nofollow">https:&#x2F;&#x2F;www.jetbrains.com&#x2F;help&#x2F;idea&#x2F;using-language-injection...</a> I have found that to be more helpful in cases where the data flow can&#x27;t or doesn&#x27;t prove how a string is being used, as in:<p><pre><code> def doit(): # language=SQL s = &quot;SELECT * FROM FOO&quot; run_sql(s) def run_sql(s: str): cur = conn.cursor() cur.execute(s) </code></pre> Although I am not certain if tree-sitter allows matching on comments, but <a href="https:&#x2F;&#x2F;github.com&#x2F;tree-sitter&#x2F;tree-sitter&#x2F;issues&#x2F;1138">https:&#x2F;&#x2F;github.com&#x2F;tree-sitter&#x2F;tree-sitter&#x2F;issues&#x2F;1138</a> seems to imply that it does