Testing new code plugin
I think I finally found a syntax highlighting code plugin that I like, so I’m giving it a shot. To test it out, here’s a bit of code from back in school that I was always a little fond of.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | let explode s = let rec explode s i = if i < String.length s then s.[i]::(explode s (i + 1)) else [] in (explode s 0) let implode l = begin let v = (String.create (List.length l)) in for i = 0 to ((List.length l) - 1) do String.set v i (List.nth l i) done; v end let lex s = let rec tok c w = match c, w with [], w -> [implode w] | (c::cs), w -> match c with ' ' -> [implode w]@(tok cs []) | '\n' -> [implode w]@(["\n"]@(tok cs [])) | '\t' -> [implode w]@(["\t"]@(tok cs [])) | _ -> tok cs (w@[c]) in tok (explode s) [] |
It’s a few utility functions used in a combinator recognizer in OCaml. Combinator recognizers are like a lite parser, simply answering if a sentence is included in a grammar, but it doesn’t provide the derivation. They can be pretty useful because they’re easy to put together and show partial matches still. Maybe I’ll go a little more in depth in the future and fully describe one with examples.
string test = "Testing a really long line to see how if it scrolls the div the way I'd like. Hopefully it does. I also should hack the plugin so that it displays a little header that says what type of code is being displayed.";
It appears everything is working beautifully. In case you’re wondering I’m using wp-syntax which in turn uses GeSHi for syntax highlighting. Was a snap to drop in place and works great. Looks pretty good too.







