diff --git a/lib/ace/ext/static_highlight.js b/lib/ace/ext/static_highlight.js index 1d69a9bb..9116467b 100644 --- a/lib/ace/ext/static_highlight.js +++ b/lib/ace/ext/static_highlight.js @@ -98,7 +98,6 @@ var highlight = function(el, opts, callback) { * and `css`. * @returns {object} An object containing the properties `html` and `css`. */ - highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) { var waiting = 1; var modeCache = EditSession.prototype.$modes; @@ -112,11 +111,17 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba --waiting || done(); }); } - + // allow setting mode options e.h {path: "ace/mode/php", inline:true} + var modeOptions; + if (mode && typeof mode === "object" && !mode.getTokenizer) { + modeOptions = mode; + mode = modeOptions.path; + } if (typeof mode == "string") { waiting++; config.loadModule(['mode', mode], function(m) { - if (!modeCache[mode]) modeCache[mode] = new m.Mode(); + if (!modeCache[mode] || modeOptions) + modeCache[mode] = new m.Mode(modeOptions); mode = modeCache[mode]; --waiting || done(); }); @@ -130,14 +135,13 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba return --waiting || done(); }; -/* +/** * Transforms a given input code snippet into HTML using the given mode * @param {string} input Code snippet * @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode') * @param {string} r Code snippet * @returns {object} An object containing: html, css */ - highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) { lineStart = parseInt(lineStart || 1, 10);