savannah-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sr #110279] Request: syntax highlighting in cgit web interface


From: Svetlana T
Subject: [sr #110279] Request: syntax highlighting in cgit web interface
Date: Thu, 23 Jul 2020 01:12:59 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Follow-up Comment #1, sr #110279 (project administration):

Hi all,

This seems doable, there is a howto with two options. To me it seems option 1
is preferred. Please see quote below:

"Cgit supports syntax highlighting when viewing blobs. To enable syntax
highlighting, you have several options.

Option 1. Using python-pygments

Install python-pygments and add the filter in /etc/cgitrc

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

To change the coloring style, modify the style argument that is passed to
HtmlFormatter in the syntax-highlighting.py file. For instance, to change the
coloring style to 'tango':

 formatter = HtmlFormatter(encoding='utf-8', style='tango')

To get a list of all coloring styles that are available, do:

 $ python
 >>> from pygments.styles import get_all_styles
 >>> list(get_all_styles())
 ['manni', 'igor', 'xcode', 'vim', 'autumn', 'vs', 'rrt', 'native', 'perldoc',
'borland', 'tango', 'emacs', 'friendly', 'monokai', 'paraiso-dark',
'colorful', 'murphy', 'bw', 'pastie', 'paraiso-light', 'trac', 'default',
'fruity']

Option 2. Using highlight

Install the highlight package.

Copy /usr/lib/cgit/filters/syntax-highlighting.sh to
/usr/lib/cgit/filters/syntax-highlighting-edited.sh. Then, in the copied file,
comment out version 2 and comment in version 3. You may want to add
--inline-css to the options of highlight for a more colorful output without
editing cgit's css file.

 # 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

Enable the filter in /etc/cgitrc

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

Note: Editing /usr/lib/cgit/filters/syntax-highlighting.sh directly would lose
all the modifications as soon as cgit is updated."

Source: https://wiki.archlinux.org/index.php/Cgit#Syntax_highlighting
Licence: Content is available under GNU Free Documentation License 1.3 or
later unless otherwise noted.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/support/?110279>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]