Method code for $code_lib.code_to_html()

[Turn on line numbering]
arg code, object, options;
var line, object_parse, results, obj_regexp, meth_regexp, chunk, word, method_parse, last_word, mode, chunk_out, meth_r2;

obj_regexp = "\$[a-zA-Z0-9_]+";
meth_regexp = "((^)|[ (!])\.[a-zA-Z0-9_]+\(";
meth_r2 = "^(\.[a-zA-Z0-9_]+\()(.*)$";
results = [];
for line in (code) {
    if (match_regexp(line, "^ *//")) {
        results += ["<font color=\"#a0a0a0\">" + line + "</font>"];
    } else {
        object_parse = line.global_regexp(obj_regexp);
        last_word = 0;
        chunk_out = "";
        while (object_parse) {
            [chunk, (word ?= 0), @object_parse] = object_parse;
            if (last_word && (method_parse = chunk.regexp(meth_r2))) {
                chunk_out += ._do_method_href(method_parse[1], last_word, options);
                chunk = method_parse[2];
            }
            method_parse = chunk.global_regexp(meth_regexp);
            mode = 0;
            chunk_out += map chunk in (method_parse) to ((mode = !mode) ? chunk : ._do_method_href(chunk, object, options)).join("");
            if (word) {
                last_word = word;
                if ((| $object_lib.to_dbref(word) |))
                    chunk_out += "<A HREF=\"/bin/display?target=" + (last_word = word).subrange(2) + "\">" + word + "</A>";
                else
                    chunk_out += word;
            }
        }
        results += [chunk_out + object_parse.join("")];
    }
}
return results;

["// Created 26-Mar-1995 as a part of ColdCore, see: @help Credit"]

the Cold Dark