如何运行cgit的syntax-highlighting.sh命令来检查它是否正常工作?

如何运行cgit的syntax-highlighting.sh命令来检查它是否正常工作?

cgit 安装中的语法突出显示选项无法正常工作,我想看看如果所有必要的参数都存在,它是否可以从命令行正常运行。

中的选项/etc/cgitrc设置正确。

source-filter=/usr/lib/cgit/filters/syntax-highlighting.sh

当我在 bash 文件上运行highlight命令时,例如 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
#!/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 dash and bash, however busybox environments
# might have to use an external call to sed instead.

#
# Code considered irrelevant snipped
#

# store filename and extension in local vars
BASENAME="$1"
EXTENSION="${BASENAME##*.}"

[ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt
[ -z "${EXTENSION}" ] && EXTENSION=txt

# map Makefile and Makefile.* to .mk
[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk

# highlight versions 2 and 3 have different commandline options. Specifically,
# the -X option that is used for version 2 is replaced by the -O xhtml option
# for version 3.
#
# Version 2 can be found (for example) on EPEL 5, while version 3 can be
# found (for example) on EPEL 6.
#
# This is for version 2
#exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null

# This is for version 3
exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2>/dev/null

答案1

事实证明,为了在 cgit 下实现语法突出显示,指定语法突出显示的行必须出现在存储库位置行之前。在下面给出的示例中,如果该source-filter行放在该include行之后,语法突出显示将失败。

source-filter=/usr/lib/cgit/filters/syntax-highlighting.py   
include=/home/infosys/sites/cgit.local/www/cgitrepos

我检查过,除非它被记录在某处,否则它一定是一个错误。也许某些设计问题需要这样。

更多信息请访问https://wiki.archlinux.org/index.php/Cgit

相关内容