taavi

Just another weblog

syntaksi higlight wordpressis

without comments

Asjad arenevad – installisin süntaksi highlightimise mooduli wordpressi jaoks. Ja nüüd tuleb “hello world” selle väljundi testimiseks:

hello() ->
    World = "world",
    io:format("Hello highlighted ~p~n", [World]).

Huvitav, kas tuleb ilus hello world!?

Ei tulnud.. Kokku tubli tund-poolteist jamamist, ets saaks enamvähem mõistliku näoga väljundi. Ei ole see javascripti http://code.google.com/p/syntaxhighlighter/ sugigi nii mõnus, kui võiks olla.

Praegune muditud koodijupp erlangi enamvähem ilusti kuvamiseks on selline:

SyntaxHighlighter.brushes.Erlang = function()
{
 var keywords = 'after begin case catch cond end fun if let of query receive when '+
  'define record export import include include_lib ifdef ifndef else endif undef '+
  'apply attribute call do in letrec module primop try';

 this.regexList = [
  { regex: /%.*$/gm,                    css: 'comment' },   // one line comments
  { regex: /"(?!")(?:\.|\\\"|[^\""\n])*"/gm,    css: 'string' },
  { regex: new RegExp(this.getKeywords(keywords), 'g'),  css: 'keyword' },
  { regex: /[A-Z][A-Za-z0-9_@]*/gm,     css: 'variable' },
  { regex: /\\w+\/\\d+/g,       css: 'funs'}
  ];

  this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
};

SyntaxHighlighter.brushes.Erlang.prototype = new SyntaxHighlighter.Highlighter();
SyntaxHighlighter.brushes.Erlang.Aliases = ['erlang', 'erl'];

Written by taavi

March 19th, 2009 at 1:57 am

Posted in progemine