Syntax highlighting
From WhyNotWiki
Syntax highlighting edit (Category edit) .
Contents |
[edit] Wish list
Let other people do the work and then benefit from it. :-)
People already write syntax highlighting extensions for vim for just about every file format (including MediaWiki syntax!)! Why not just write a converter or vim syntax file reader and use those existing files? Or maybe that would be too hard.
[edit] Things that need syntax highlighting
- programming languages
- Diff files (+ lines are blue, - are red, for example)
[edit] CSS Classes
Get typocode CSS classes (example: http://blog.teksol.info/articles/tag/engines) for nice formatting of code blocks
CSS, Ruby, YAML stylesheets available here: http://source.onrails.org/repository/browse//BrowseSource/vendor/syntax/data
[edit] Software / Libraries
[edit] GeSHi - Generic Syntax Highlighter
Can be used on MediaWiki (see [1] for an example).
[edit] Syntaxi
| Project/Development: | http://rubyforge.org/projects/syntaxi/
|
|---|---|
| Description: | Syntaxi provides a way to format code snippets in text (e.g. in a weblog) into syntax colored, line numbered, and line wrapped HTML for display on a webpage. It uses the Syntax library to do the tokenization for syntax coloring.
|
[edit] CodeRay
require 'coderay'
require 'find'
require 'fileutils'
Find.find('./') do |path|
if File.basename(path) == '.svn'
Find.prune
next
end
if path =~ /\.rb$/
output_path = "html/#{path}.html"
FileUtils.mkdir_p(File.dirname(output_path))
puts "Processing #{path}..."
tokens = CodeRay.scan File.read(path), :ruby
File.open(output_path, 'w') do |path|
path.puts %q(<link rel="stylesheet" href="coderay.css" type="text/css" />)
path.puts tokens.div(:line_numbers => nil, :css => :class)
end
end
end
[edit] RHighlight
| Project/Development: | http://rubyforge.org/projects/rhighlight/
|
|---|---|
| Description: | RHighlight provides Ruby bindings for the syntax highlighting program "highlight", http://www.andre-simon.de/. Featuring colored output HTML, XHTML, RTF, TeX, LaTeX and XML, and 120+ programming languages.
|
| Readiness: | Registered: 2006-08-28, This Project Has Not Released Any Files 2007-03-23 18:48
|
[edit] Syntax highlighting in OpenOffice Impress presentations
http://www.google.com/search?q=syntax+highlighting+impress+presentation syntax highlighting impress presentation - Google Search
http://www.mail-archive.com/linux-il@cs.huji.ac.il/msg46881.html Re: Syntax highlighting of makefiles in OpenOffice (solved)
- enscript
- vim2html
- geshi
Apparently HTML can then be imported into Impress?
[edit] Syntax highlighting in MediaWiki
MediaWiki / Syntax highlighting edit
In the future: I'm keeping my eyes open for a good extension to do this for me...
In the meantime: Just put all code blocks in <pre> tags...
Also, you can feel free to start encoding the language of the block, so that when we finally do get a syntax highlighting extension/feature, we already know which language should be used for syntax highlighting for each block...
Valid language options are:
console: commands typed in the shell / on the command linebash: a bash scriptmediawiki: MediaWiki wikitext markupruby- ... (the rest should be intuitive enough to guess)
Example:
<pre class='console'> > svn propset svn:externals "rails http://dev.rubyonrails.org/svn/rails/trunk" vendor </pre>
> svn propset svn:externals "rails http://dev.rubyonrails.org/svn/rails/trunk" vendor
These classes defined here: MediaWiki:Common.css edit
