Difference between revisions of "Syntax Highlighting"

From Freephile Wiki
Jump to navigation Jump to search
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Feature
 
|image=Syntax.jpg
 
|imgdesc=Code highlighting
 
|title=
 
}}
 
{{#set:feature description = syntax highlighting is available for dozens of languages through the [[mw:Extension:SyntaxHighlight_GeSHi]] and the underlying [[Python]] [http://pygments.org/ Pygments] library }}
 
{{#set:feature notes =  }}
 
{{#set:feature tests =  }}
 
{{#set:feature examples = [[Apache]] shows config file highlighting; [[Library]] shows JavaScript; etc. }}
 
 
 
 
== Syntax Highlighting in Quanta ==
 
== Syntax Highlighting in Quanta ==
 
Quanta has syntax defintion files which are called 'DTEP' files.
 
Quanta has syntax defintion files which are called 'DTEP' files.

Revision as of 16:21, 9 December 2008

Syntax Highlighting in Quanta[edit | edit source]

Quanta has syntax defintion files which are called 'DTEP' files. See the quanta dev list, website, or help:/quanta (Quanta Manual in konqueror). These files are stored in

# application directory
/usr/share/apps/quanta/dtep/
# local user directory
~/.kde/share/apps/quanta/dtep/

placing a new directory, which includes all tag definitions, in one of those locations will provide all the info Quanta needs to understand the syntax. On the Quanta site there is a DTEP for TaskJuggler syntax.

Syntax Highlighing in VIM[edit | edit source]

To add syntax highlighting for a particular language or syntax, you need to have a syntax definition file, and then you need to 'turn it on' by setting it up in your local configuration file. For example, there is a syntax file for TaskJuggler, which can be turned on thusly:

sudo cp /usr/local/src/taskjuggler-2.2.0/Contrib/vim/tjp.vim  /usr/share/vim/vimcurrent/syntax/
sudo chmod o+r /usr/share/vim/vimcurrent/syntax/tjp.vim
echo 'if has("autocmd")
augroup taskjuggler
au! BufNewFile,BufRead *.tj{p,i} set ft=tjp
augroup END
endif' >> ~/.vimrc

Syntax Highlighting in Konsole[edit | edit source]

Syntax Highlighting in Websvn[edit | edit source]

The current syntax highlighting in websvn is handled via GNU enscript

Syntax Highlighting in MediaWiki[edit | edit source]

(Note that there is also a MediaWiki/Syntax highlighting article) Writing good code, especially in open source context, requires illustrating best practices and tutorials. Those tutorials are made ever more useful with syntax highlighting.

MediaWiki is able to incorporate a nice 3rd-party project called Generic Syntax Highlighter or GeSHi for short. Fortunately GeSHi is now packaged with debian for easy installation on Debian or Debian-based systems. There is a mw:Extension:SyntaxHighlight_GeSHi extension which provides a tie-in between MediaWiki and GeSHi. (note that there are a few different GeSHi extensions for mediawiki, and we use the one in use on mediawiki.org http://www.mediawiki.org/wiki/Special:Version).

To install the actual GeSHi software package (it installs in /usr/share)

sudo apt-get install php-geshi
ls /usr/share/php-geshi/
contrib  geshi  geshi.php

Incorporating GeSHi into Mediawiki is just a matter of adding the extension to the source tree and including it in LocalSettings.

Usage[edit | edit source]

See the mw:Extension:SyntaxHighlight_GeSHi#Examples


<source lang="php"> $v = array_pop($foo); // just a comment </source>

Supported Languages[edit | edit source]

mw:Extension:SyntaxHighlight_GeSHi#Supported_languages

Documentation[edit | edit source]

See http://qbnz.com/highlighter/geshi-doc.html for the extensive documentation. GeSHi is used in a number of other software projects like

  • Dokuwiki - An advanced wiki engine
  • gtk.php.net - Their manual uses GeSHi for syntax highlighting
  • WordPress - A powerful blogging system*
  • PHP-Fusion - A constantly evovling CMS
  • SQL Manager - A Postgres DBAL
  • Mambo - A popular open source CMS
  • MediaWiki - A leader in Wikis*
  • TikiWiki - A megapowerful Wiki/CMS
  • TikiPro - Another powerful Wiki based on Tikiwiki
  • RWeb - A site-building tool