Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Useful source syntax highlighting front-end GUI utility.

License

rweckert/shLight

Repository files navigation

shLight

Useful source syntax highlighting front-end GUI utility.

Script Purpose as a Tool:

The shLight script allows the process of converting source code of varying languages to syntax highlighted HTML documents with options of different styles. shLight allows the option to convert a single document or a batch list of documents with ease.

shLight Screenshot

Setup:

  1. Please review "Common System Requirements" and "Critical System Requirements" sections below for basic and critical requirements to run this script successfully.
  2. Save the shLight.sh file to a directory.
  3. Make the shLight.sh script executable by running the following command in the same directory as the shLight.sh file:
    chmod +x shLight.sh

Features:

  • Convert a single document for syntax highlighting conversion.
  • Convert multiple documents for syntax highlighting conversion.
  • Select output folder for single or multiple syntax highlighting conversions.
  • Supports over 40 different styles for syntax highlighting output.
  • Supports over 170 different source language types for syntax highlighting conversion.
  • Optional "Line Numbering" for output for both single or multiple syntax highlighting conversions.
  • Single syntax highlighting conversion allows output to contain a document title.
  • Browse output folder for both single or multiple syntax highlighting conversions.
  • Use the 'F1' key for documentation from any main window.

Typical Usage:

When opening shLight select either the option for "Convert" to convert a source file to a HTML syntax highlighted document or "Multiple" for multiple files to be converted at once. In either option, you will be directed to a window asking for input of the file(s) of source to be converted. Options include "Source", "Language", "Output Folder", and "Syntax Style" as well as "Line Numbers". Over 170 source languages and over 40 different document styles are supported. After making selections click on the appropriate convert button to then view results ready for publishing.

Detailed Options and Usage:

When opening the shLight script the main menu will appear with the following options:
- Convert: Opens the "Convert Menu" to convert a single source file.
- Multiple: Opens the "Convert Multiple Menu" to convert a multiple source files.
- View: Views the last single converted file.
- Languages: Displays a list of all supported code languages available for conversion.
- Options: Allows options for a theme to be selected for use by the scripts menus and windows.
- Exit: Closes the shLight script including all menus and windows.

Convert Menu:

This option allows syntax highlight conversion of a single file, contains the following options:
- Source File: Select a single file for syntax highlighting conversion.
- Language: Select a language of the source file. If the source file language is not listed, click on the "Languages" main menu option for a complete list and type in the language needed into this field.
- Output Folder: Select the output folder for the syntax highlighted file.
- Output File: Type in a filename for the syntax highlighted convert file.
- Output Title: Apply a title for the syntax highlighted convert file.
- Line Numbering: Select if each line of the syntax highlighted convert file will be numbered. Options are "True" or "False".
- Syntax Style: Select the style of the syntax highlighted convert file. The option "Default" is the primary selection.
- Convert Source: Select this button to convert a source file using the input from the above fields. If fields used for a successful conversion are not filled a error will occur.
- Close Convert: Closes the "shLight Convert" window.

View:

After a conversion of a single file this feature will display the converted syntax. These options include:
- Open Folder: Opens the folder that contains the output file for browsing using the systems default file management application.
- Edit Output: Opens the source of the converted file using the systems default text editor.
- Print Output: Opens the "Print Dialog window to print the output file.
- Close Viewer: Closes the "shLight View" window.

Multiple:

This option allows syntax highlight conversion of multiple files at once:
- Source Files: Select a multiple files for syntax highlighting conversion.
- Language: Select a language of the source files. If the source file language is not listed, click on the "Languages" main menu option for a complete list and type in the language needed into this field.
- Output Folder: Select the output folder for the syntax highlighted files.
- Syntax Style: Select the style of the syntax highlighted convert files. The option "Default" is the primary selection.
- Line Numbering: Select if each line of the syntax highlighted convert files will be numbered. Options are "True" or "False".
- Convert Multiple: Select this button to convert multiple source files using the input from the above fields. If fields used for a successful conversion are not filled a error will occur.
- Close Convert: Closes the "shLight Multiple" window.

Multiple Convert List:

Provides a list of the multiple files that have been converted. These options include:
- Double Click: Performing a double mouse click on a listed file that has been converted will open the users default web browser for viewing.
- Browse Output: Opens the folder that contains the multiple output files for browsing using the systems default file management application.
- Export List: Exports the list viewed to the systems default text editor.
- Close List: Closes the "shLight Multiple List" window.

Languages:

This is the complete language list that is supported for conversion. If the source syntax type is not listed in the "Language" pull down menu, you can review this list of supported languages and type in the language tag value for the "Language" conversion option manually. This list is derived directly from the installed "source-highlight" package.
- Close: Closes the "shLight-Languages" window.

Theme Options:

The "Theme" main menu option allows the user to change settings for the theme being used, as well as access to "Help" and "About" options:
- Load Theme: Allows the user to browse their system for a theme to use.
- Apply Loaded Theme: Applies the loaded theme. Once selected the Options window will close and re-open showing the theme selected in use.
- Mode: Select basic system theme available in the system for "Light Theme" or "Dark Theme". This default uses the "Breeze" theme package located in the "/usr/share/themes/" folder.
- Apply System Theme: Applies the Mode selected for either "Light Theme" or "Dark Theme". Once selected the Options window will close and re-open showing the theme selected in use.
- Browse Themes Folder: Browse the default themes folder "/usr/share/themes/".
- Help: Opens shLight help documentation.
- About: Opens the about window showing script credits.
- Close: Closes the "Options" window.

Notes:

  • shLight can be ran from any directory.
  • shLight uses the /tmp/ folder for temporary and .ini files.
  • The main menu option for "View" will display the last single highlighting conversion made. If a conversion file is not found a message will appear stating that you must first perform a conversion before viewing.
  • To access a list of previous multiple conversions, select "Multiple" from the main menu and then inside the "shLight Multiple" window select "Multiple Result List".
  • Creating a highlighted conversion for either single or multiple files, the fields for "Source", "Language", "Output Folder", and "Syntax Style" must be filled or a error pointing out what field was not filled will appear.
  • The "Language" option from the main menu will display a list of all source languages that the installed source-highlight package supports. This is shown as a seperate list as the list being over 170 languages is too large for the menu to be usable. The "Language" pull down option for both single and multiple conversions allow a language not listed to be typed in.
  • The list of over 40 different document styles available for use are directly from the installed source-highlight package. These *.css style sheet files can be found in the "/usr/share/source-highlight/" folder.
  • All temporary files created by shLight are removed once the shLight script closes.
  • Use the 'F1' key for documentation from any main window.

cImage Shortcut File:

Save the following as a file named "shLight.desktop" in creating a shortcut to this utility. Update the path for "Exec" to where the script is stored:
[Desktop Entry]
Name=shLight
GenericName=shLight
Comment=Useful source syntax highlighting front-end GUI utility.
Exec=/PathToScript/shLight.sh
Type=Application
Icon=gtk-select-color
Terminal=false

Common System Requirements:

Common shell commands found in most Linux installations are used to provide system functionalilty for this and other scripts shared from this profile. For thoroughness, these common shell commands are listed in alphabetical order with version and man page link for review: https://github.com/rweckert/shLight/blob/750ca2bc14503ec4c84248cfff59cd52bf22f8af/README-Basic-Requirements.md

Critical System Requirements:

Packages listed below provide the core ingredients for graphic display and desired output that enables shLight deliver output and are critical for successful execution of the the script:

Package Version Notes
yad 14.0+ (GTK+ 3.24.41) A tool for developing graphical user interfaces in Linux and is used by this script to generate menus and dialog windows, is written by Victor Ananjevsky. Download: https://github.com/v1cont/yad Setup: Step by step instructions are available for either Linux or Microsoft Windows Subsystem for Linux (WSL) using a Debian base: https://github.com/rweckert/yad-14.0-Setup-From-Scratch
source-highlight 3.1.9 (library: 4:1:0) The source-highlight package is used to convert source code to syntax highlighted documents. Written by Lorenzo Bettini http://www.lorenzobettini.it More information regarding this package can be found at: https://linux.die.net/man/1/source-highlight and also https://www.gnu.org/software/src-highlite/.

Closing:

Script interface written by: Robert W. Eckert - [email protected] Please feel free to email to submit bugs, changes or requests. This script comes with absolutely no warranty. See the link for the GNU General Public License, version 3 or later listed below for further details.


Project Contents:

Project Page:
https://github.com/rweckert/shLight
Source File:
https://github.com/rweckert/shLight/blob/5122f14ae9feba6d896d7323dbe5200fbc9fc2bf/shLight.sh
Documentation File:
https://github.com/rweckert/shLight/blob/5122f14ae9feba6d896d7323dbe5200fbc9fc2bf/README.md
Project Screenshot:
https://github.com/rweckert/shLight/blob/5122f14ae9feba6d896d7323dbe5200fbc9fc2bf/screenshot-shLight.jpg
Project Licensing:
https://github.com/rweckert/shLight/blob/5122f14ae9feba6d896d7323dbe5200fbc9fc2bf/LICENSE
GitHub Profile Page:
https://github.com/rweckert

Releases

No releases published

Packages

No packages published

Languages