helpSavannah Administration - Support: sr #110279, Request: syntax highlighting in...

 
 

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

Submitted by:  Eric Bavier <bavier>
Submitted on:  Thu 23 Jul 2020 03:31:08 AM UTC  
 
Category:  Source code repositories - web browsing Priority:  5 - Normal
Severity:  1 - Wish Status:  None
Assigned to:  Amin Bandali <bandali> Operating System:  None
Open/Closed:  Open

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 06 Sep 2020 02:54:30 AM UTC, comment #3: 

From past experience with cgit on my personal server, adding the
python-pygements-based highlighter adds a quite noticeable delay to the
load time of source view of all files, possibly due it being written in
Python, which is not exactly known for its speed.

The highlight-based highlighter, on the other hand, did not add any
noticeable amount of time to the page loads of source views on that
server of mine.

I will experiment with the highlighters for Savannah cgit and see if we
could feasibly use one of them, considering that Savannah has a much
larger and more regular viewing audience (i.e. greater system load)
compared to my personal server).

Amin Bandali <bandali>
Site AdministratorIn charge of this item.
Sun 06 Sep 2020 02:24:27 AM UTC, comment #2: 

Hello,

Probably we should consider client-side syntax highlighting as well.

Doing it on the server-side will increase load. Though I'm not sure about impact and weather its acceptable or not.

Anatoly A. Kazantsev <jimcrow>
Thu 23 Jul 2020 05:12:58 AM UTC, comment #1: 

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.

Svetlana T <svetlana>
Thu 23 Jul 2020 03:31:08 AM UTC, original submission:  

I was wondering if we could enable syntax highlighting in cgit's web interface when browsing source files?  From my little bit of research, it seems cgit can use python-pygments or the "highlight" utility with only a small amount of configuration needed.

Please consider.  I think this would make the browsing experience much nicer.

Eric Bavier <bavier>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bandali (Posted a comment)
  • -email is unavailable- added by jimcrow (Posted a comment)
  • -email is unavailable- added by svetlana (Posted a comment)
  • -email is unavailable- added by bavier (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-09-06 bandali Assigned toNone => bandali

    Back to the top


    Powered by Savane 3.5