Skip to content

gorb314/pylite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pylite

A python-based code-to-html syntax highlighter

The code is currently in very basic alpha status.

That means: use at your own risk.

Requirements

pylite currently requires python 2.x, because of "import cgi" which is used to escape to html.

Install

See INSTALL.

Usage

From the source:

Usage: pylite [-e <CSS>] [-i] [-s] [-p <PAT>] [-m <MSG>] <FILENAME>
where
   -e <CSS>    use specified external stylesheet CSS
   -i          use inline styles
   -s          output snippet
   -p <PAT>    force usage of pattern PAT
   -m <MSG>    display caption as "filename: MSG"
   <FILENAME>  the file to style
The default behaviour is to produce a full html5 webpage with embedded
stylesheet. The pattern is by default taken from the file extension.
By default no caption is displayed.
The output is sent to stdout.

Example

$ cat simple.c

int main()
{
	return 0;
}

$ pylite -m "" simple.c > simple.html


simple.c: 
1 2 3 4 int main() { return 0; }

Internals

The code follows a very simple yacc/flex-like lexing format, where tokens are defined using regexes.

Lexing "states" are supported, so that multi-line regexes can be performed.

Output is simply <span>'ed as classes, letting the style.css take care of the appearance of the <pre>-formatted output.

TODO

See all TODOs in src/pylite.

About

A python-based code-to-html syntax highlighter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published