Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 自定义升华插件中的高亮显示_Python_Regex_Sublimetext_Sublimelinter - Fatal编程技术网

Python 自定义升华插件中的高亮显示

Python 自定义升华插件中的高亮显示,python,regex,sublimetext,sublimelinter,Python,Regex,Sublimetext,Sublimelinter,我开始为它编写插件,到目前为止,linting本身正在工作。然而,我还没有成功地开始工作。因为我的linter(实际上是一个编译器)不输出列,所以如果失败的行被突出显示,我会很高兴 linter.py中的相关部分如下所示: regex = ( r'Error in script \".+?\" on line (?P<line>\d+) -- aborting creation process' ) multiline = True line_col_base = (1, 1)

我开始为它编写插件,到目前为止,linting本身正在工作。然而,我还没有成功地开始工作。因为我的linter(实际上是一个编译器)不输出列,所以如果失败的行被突出显示,我会很高兴

linter.py
中的相关部分如下所示:

regex = (
  r'Error in script \".+?\" on line (?P<line>\d+) -- aborting creation process'
)
multiline = True
line_col_base = (1, 1)
Invalid command: Naem
Error in script "/Users/testuser/Desktop/lint-test.nsi" on line 5 -- aborting creation process
我不知道SublimeLiner如何利用错误消息,所以我很高兴现在就可以得到线路部分

编辑:根据下面的评论,我尝试使用附近的
,但由于缺少文档和示例,我仍然没有找到解决方案。我更新的正则表达式模式:

regex = (
  r'Invalid command\: (?P<near>\w+)'
  r'Error in script \"(.+?)\" on line (?P<line>\d+) -- aborting creation process'
)
regex=(
r'无效命令\:(?P\w+)
第(?P\d+)行的“脚本\”(.+?)\”中出现错误--正在中止创建过程”
)

尽管这只会捕获拼写错误的命令,但答案可以让我更容易理解如何正确捕获输出。

以下是我最终使用的:

syntax = 'nsis'
    regex = (
        r'(?P<message>[^\r?\n]+)\r?\n'
        r'(?P<error>Error) in script "[^"]+" on line (?P<line>\d+) -- aborting creation process'
    )
    multiline = True
    error_stream = util.STREAM_STDOUT
    line_col_base = (1, 1)
语法='nsis'
正则表达式=(
r'(?P[^\r?\n]+)\r?\n'
脚本“[^”]+”中的r'(?peror)位于第行(?P\d+)--中止创建过程'
)
多行=真
错误\u stream=util.stream\u STDOUT
行列基=(1,1)

如果我没记错的话,是因为缺少换行符。

SublimeLineter指定“near”作为参数,如果插件不返回列。你能在near组中捕获“Naem”吗?或者只是覆盖提取方法:@alkuzad谢谢你的提示,这对无效命令应该有效。周末将尝试一下!