Difference between revisions of "HaskellWiki:Syntax highlighting"
(→Styles) |
|||
(11 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
− | '''Syntax highlighting''' works for a bunch of languages including Haskell, using GeSHi and Jason Dagit's Haskell file, somewhat modified. |
+ | '''Syntax highlighting''' works for a bunch of languages including Haskell, using [http://qbnz.com/highlighter/ GeSHi] and [http://web.archive.org/web/20070503183148/http://www.codersbase.com/index.php/Geshi_haskell Jason Dagit's Haskell file], somewhat modified. |
== Block formatting with <code><haskell></code> == |
== Block formatting with <code><haskell></code> == |
||
Line 11: | Line 11: | ||
import Prelude |
import Prelude |
||
− | foo :: (Monad m) |
+ | foo :: (Monad m) => m (Int,Int) |
foo = (x-2,x - 1) where |
foo = (x-2,x - 1) where |
||
x = 3 |
x = 3 |
||
Line 27: | Line 27: | ||
Inline highlighting is a bit of a hack at the moment, and may be buggy. |
Inline highlighting is a bit of a hack at the moment, and may be buggy. |
||
+ | |||
+ | :It is indeed, see [[User:benmachine/hasktag bug]] --[[User:Benmachine|benmachine]] 01:56, 5 September 2012 (UTC) |
||
+ | |||
+ | :I would recommend using the <code> tag instead which seems to do less damage. Though that page that [[User:Benmachine|benmachine]] has linked to now seems fine to me, I've noticed that use of <hask> within a paragraph will result in poor spacing against surrounding paragraphs and <haskell> blocks. Essentially, having <hask> seems to result in the text not being put in a paragraph <p> block -- [[User:Michael Jones|Michael Jones]] 13 December 2013 |
||
== Styles == |
== Styles == |
||
Line 34: | Line 38: | ||
This is what I am trying to achieve: |
This is what I am trying to achieve: |
||
− | * comments: |
+ | * comments: grey |
* keywords (including symbols): blue |
* keywords (including symbols): blue |
||
− | * value literals: dark |
+ | * value literals: dark green |
− | * known value identifiers (including symbols): |
+ | * known value identifiers (including symbols): green |
− | * known type identifiers: |
+ | * known type identifiers: red |
* known classes: purple |
* known classes: purple |
||
* known modules: brown |
* known modules: brown |
||
+ | I also indent the entire block by 2em. See [[MediaWiki:Common.css]]. |
||
⚫ | |||
+ | |||
⚫ | |||
== Other languages == |
== Other languages == |
||
− | This works for certain other languages too. For lisp, for instance, use <code><pre-lisp></code>...<code></pre-lisp></code> to format a block of lisp, and <code><code-lisp></code>...<code></code-lisp></code> to format text inline. <code><haskell></code> the same as <code><pre-haskell></code> and <code><hask></code> the same as <code><code-haskell></code>. |
+ | This works for certain other languages too. For lisp, for instance, use <code><pre-lisp></code>...<code></pre-lisp></code> to format a block of lisp, and <code><code-lisp></code>...<code></code-lisp></code> to format text inline. <code><haskell></code> is the same as <code><pre-haskell></code> and <code><hask></code> is the same as <code><code-haskell></code>. |
Latest revision as of 03:23, 13 December 2013
Syntax highlighting works for a bunch of languages including Haskell, using GeSHi and Jason Dagit's Haskell file, somewhat modified.
Block formatting with <haskell>
To highlight syntax of a block of Haskell, enclose it in <haskell>
...</haskell>
. This uses the <pre>
element. For instance:
{-
My program
-}
import Prelude
foo :: (Monad m) => m (Int,Int)
foo = (x-2,x - 1) where
x = 3
-- The main function
main :: IO ()
main = do
a <- foo
putStr ("And the answer is: " ++(show (fst a))++"\n")
Inline formatting with <hask>
To highlight syntax of inline Haskell snippets, enclose the span in <hask>
...</hask>
. This uses the <code>
element, which is inline. For instance: import Prelude
.
Inline highlighting is a bit of a hack at the moment, and may be buggy.
- It is indeed, see User:benmachine/hasktag bug --benmachine 01:56, 5 September 2012 (UTC)
- I would recommend using the <code> tag instead which seems to do less damage. Though that page that benmachine has linked to now seems fine to me, I've noticed that use of <hask> within a paragraph will result in poor spacing against surrounding paragraphs and <haskell> blocks. Essentially, having <hask> seems to result in the text not being put in a paragraph <p> block -- Michael Jones 13 December 2013
Styles
For Haskell (only) I have deliberately removed all formatting apart from foreground colour, and those I have tried to keep dark so as not to be visually distracting.
This is what I am trying to achieve:
- comments: grey
- keywords (including symbols): blue
- value literals: dark green
- known value identifiers (including symbols): green
- known type identifiers: red
- known classes: purple
- known modules: brown
I also indent the entire block by 2em. See MediaWiki:Common.css.
—Ashley Y 10:49, 19 March 2006 (UTC)
Other languages
This works for certain other languages too. For lisp, for instance, use <pre-lisp>
...</pre-lisp>
to format a block of lisp, and <code-lisp>
...</code-lisp>
to format text inline. <haskell>
is the same as <pre-haskell>
and <hask>
is the same as <code-haskell>
.