我正在尝试为 gtksourceview 编写自己的语法突出显示。如果完成,它应该在文本文件中突出显示吉他和弦。这是我未完成的文件:
<?xml version="1.0" encoding="UTF-8"?>
<language id="tab" _name="Tab" version="2.0" _section="Others">
<metadata>
<property name="mimetypes">text/plain</property>
<property name="globs">*.txt;*.tab</property>
</metadata>
<styles>
<style id="chord" _name="Chord" foreground="blue" bold="true"/>
</styles>
<definitions>
<context id="chord" style-ref="chord" class="no-spell-check">
<match>[A-H]</match>
</context>
<context id="tab">
<include>
<context ref="chord"/>
</include>
</context>
</definitions>
</language>
Run Code Online (Sandbox Code Playgroud)
我希望突出显示的文本中每个大写字母 A 到 H 都是蓝色且粗体的。将文件保存到/usr/share/gtksourceview-3.0/language-specs,我可以在 GEdit 中选择它。但文本中没有突出显示任何内容。
谁能告诉我我做错了什么?
当我在 中编辑配置文件时vi,似乎vi知道文件的语法。
例如,vi将根据它是键还是值来以一种或另一种方式为标记着色。此外,vi似乎还知道哪些值是有效键。
它是如何做到这一点的?
编辑:让我补充一点,我正在运行 Ubuntu Server 12.04 LTS(精确穿山甲)
我使用它nano作为文件类型的标准编辑器,它没有内置LilyPond的语法突出显示功能。尽管我在行尾遗漏了很多空白字符,但这并不是我真正需要的。当然,我可以批量删除它们,如从文件中删除尾随空格中所述。
但以某种方式启用此功能应该不会太难,因此我可以从头开始编写更干净的代码。
有人知道该怎么做吗?
就像nanoshell 脚本一样。
我在 bashrc 文件中使用以下几行已经有一段时间了,现在突然出现错误。以下是几行:
make()
{
/usr/bin/make "$@" 2>&1 | sed -E -e "s/error/ $(echo -e "\\033[31m" ERROR "\\033[0m"/g)" -e "s/warning/ $(echo -e "\\033[0;33m" WARNING "\\033[0m"/g)"
return ${PIPESTATUS[0]}
}
Run Code Online (Sandbox Code Playgroud)
这是错误:
bash: /home/username/.bashrc: line 175: syntax error near unexpected token `('
bash: /home/username/.bashrc: line 175: `make()'
Run Code Online (Sandbox Code Playgroud) 通常,当我通过 SSH 编辑一个小文件时,我只会打开 nano。我仔细查看了我的 apache2 access.log。由于我没有在此框上启用 fail2ban 或任何功能,因此我通常也会查看 access.log.1。我注意到在我的 access.log.(#) 一个特定的行总是有一个奇怪的突出显示:
GET /w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1" 400 516 "-" "-"

我注意到的更多事情:
syntax "man" "\.[1-9]x?$"我得到的文件 .1 到 .9 的行中突出显示.. 但为什么呢?显然 /usr/share/nano 中的文件处理语法突出显示,经过一番挖掘,我发现特别是一个文件负责这个:man.nanorc。以下是它的内容:
## Here is an example for manpages.
##
syntax "man" "\.[1-9]x?$"
color green "\.(S|T)H.*$"
color brightgreen "\.(S|T)H" "\.TP"
color brightred "\.(BR?|I[PR]?).*$"
color brightblue "\.(BR?|I[PR]?|PP)"
color brightwhite "\\f[BIPR]"
color yellow "\.(br|DS|RS|RE|PD)"
Run Code Online (Sandbox Code Playgroud)
对于 wordpress …
cgit 安装中的语法突出显示选项无法正常工作,如果所有必要的参数都存在,我想看看它是否可以从命令行正常运行。
中的选项/etc/cgitrc设置正确。
source-filter=/usr/lib/cgit/filters/syntax-highlighting.sh
例如,当我在highlightbash 文件上运行命令时,css 和 span 类在输出中,但是当我在文件上运行 /usr/lib/cgit/filters/syntax-highlighting.sh 时,css 和 span 标签不会展示。
highlight脚本中的命令实际命令(最后一行)是
exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2>/dev/null
Run Code Online (Sandbox Code Playgroud)
#!/bin/sh
# This script can be used to implement syntax highlighting in the cgit
# tree-view by refering to this file with the source-filter or repo.source-
# filter options in cgitrc.
#
# This script requires a shell supporting the ${var##pattern} syntax.
# It is supported by at least …Run Code Online (Sandbox Code Playgroud) 例如,当使用 ack 在源文件中搜索代码时,输出高亮显示。但是,如果将输出通过管道传输到本地文件,则会丢失代码亮点。我们是否有命令行工具来保留它?
要理解我的意思:
$ git clone https://github.com/koehlma/jaspy
$ cd jaspy/
$ ack func ./* # you see the high light for each match
$ ack func ./* > output.txt
$ cat output.txt # you don't see the high light
Run Code Online (Sandbox Code Playgroud) 我正在寻找一个类似cat但语法高亮的程序。例如,我想在终端中突出显示我的 Python 脚本之一的内容,而不像我们使用cat filename.py.
我正在寻找一个带有 DOT 语言语法高亮显示的 Debian 编辑器。
nano ×2
bashrc ×1
cat ×1
command-line ×1
debian ×1
editors ×1
graphviz ×1
gtk ×1
highlighting ×1
ssh ×1
vi ×1
vim ×1
whitespace ×1