Code highlighting examples

Submitted by dylan on Thu, 2006-12-14 22:24.

Posting code snippets: style considerations

Several methods exist within the drupal CMS for posting code snippets. The geshifilter module will automatically highlight several languages. The 'R' language is missing, so it might be a good idea to write a language file for it. The geshfilter code block is implemented with the following tags. Note that you must specify the language type: i.e. 'sql', 'bash', 'php', 'python', etc.

<blockcode type="sql">
.... something here .....
</blockcode>


Examples

 
SQL

 -- this is a comment
SELECT pedon_id FROM description WHERE   pedon_id IN (SELECT pedon_id
FROM
(
SELECT pedon_id, name, (bottom - top) AS thick
FROM horizon
WHERE name ~ '^.?A.?|^.?O.?|^.?B.?' = 't' AND name ~ '^[[:digit:]]' = 'f'
) AS a
GROUP BY pedon_id
HAVING sum(a.thick) < 50 )

 
R

 # this is a comment
x <- read.csv('file.csv')
plot(x)
q()
done

( categories: )