Wiki
Version 3 (modified by Chuck, 8 years ago)

--

We have morphed the original Cobra highlighter for  Pygments provided by "TheManiac" to include the very latest the the Cobra Programming language supports. TheManiac started this work, which is very important because Pygments drives  other projects such as  Trac. Please find the forum discussion surrounding the earlier development at  specific forum post.

Getting started with Pygments

The most common scenario for using Pygments is converting source code to HTML. Cobra provides this support using the CobraLexer found in the dotnet.py file. dotnet.py is attached to this page.

If you already have Pygments installed skip to the next paragraph, else install Pygments using one of the ways mentioned on the  Pygments download page.

The following assumes that your main Pygments directory is named "pygments". 1. Change your directory to pygments/pygments/lexers 2. Overwrite the existing dotnet.py file with the file attached below 3. Execute the command "python _mapping.py" And you are all set.

Usage

Change your directory back to the Pygments root directory (in there you will see pygmentize).

To convert a Cobra source file to HTML use the following command:

./pygmentize -l cobra -f html -O full,style=colorful -o <output filename>.html <input file>.cobra

Above the -l option specifies the input language--Cobra in this case--and, the -f option specifies the output format. Pygments is able to infer the language and output formats when an applicable extension is used for the output file and input filenames, respectively. The above could be shortened to:

./pygmentize -O full,style=colorful -o <output filename>.html <input file>.cobra

By default the Cobra lexer will set the tabsize to 4 per Cobra public guidelines.

How do you list all the available styles and output formats? How do you change the input/output encoding? For these and other questions consult the  Pygments command line help web page.

See Also

Attachments

  • dotnet.2.py Download (22.3 KB) - added by todd.a 7 years ago.
  • dotnet.py Download (22.5 KB) - added by todd.a 7 years ago. Moved operators to a group and included this group in the root and matches within open/close parens like initializations and method calls.
  • dotnet.3.py Download (22.2 KB) - added by todd.a 6 years ago. Fixes to handle more cases for generics.
  • dotnet.4.py Download (22.3 KB) - added by todd.a 5 years ago. Updated to fix edge case with a typelist before block comments.