accept mode options object in static highlight extension
This commit is contained in:
parent
f3d4147f6b
commit
80f42e13ff
1 changed files with 9 additions and 5 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue