Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
CodeMirror.defineMode("aime-markdown", function(cmCfg, modeCfg) {
var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
function getMode(name) {
if (CodeMirror.findModeByName) {
var found = CodeMirror.findModeByName(name);
if (found) name = found.mime || found.mimes[0];
}
var mode = CodeMirror.getMode(cmCfg, name);
return mode.name == "null" ? null : mode;
}
// Should characters that affect highlighting be highlighted separate?
// Does not include characters that will be output (such as `1.` and `-` for lists)
if (modeCfg.highlightFormatting === undefined)
modeCfg.highlightFormatting = false;
// Maximum number of nested blockquotes. Set to 0 for infinite nesting.
if (stream.match('{{')) {
// tslint:disable-next-line:no-conditional-assignment
while ((ch = stream.next()) != null)
if (ch === '}' && stream.next() === '}') {
stream.eat('}');
return 'mustache';
}
}
while (stream.next() != null && !stream.match('{{', false)) {
continue;
}
return null;
}
};
return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || 'text/html'), mustacheOverlay);
});
CodeMirror.defineMode('markdown', (cmCfg, modeCfg) => {
const htmlMode = CodeMirror.getMode(cmCfg, 'text/html');
const htmlModeMissing = htmlMode.name === 'null';
function getMode(name) {
let current = name;
if (CodeMirror.findModeByName) {
const found = CodeMirror.findModeByName(current);
if (found) {
current = found.mime || found.mimes[0];
}
}
const mode = CodeMirror.getMode(cmCfg, current);
return mode.name === 'null' ? null : mode;
}
// Should characters that affect highlighting be highlighted separate?
// Does not include characters that will be output (such as `1.` and `-` for lists)
import "codemirror/mode/javascript/javascript";
import "codemirror/mode/markdown/markdown";
import "codemirror/mode/css/css";
import "codemirror/mode/htmlmixed/htmlmixed";
// FIXME perhaps python should only load if used, but this is fine for now
import "codemirror/mode/python/python";
export const delimLineRegex = /^%%\s*(\w*)/;
const innerModes = {
js: CodeMirror.getMode(
{ indentUnit: 2, statementIndent: 2 },
{ name: "javascript" }
),
py: CodeMirror.getMode(
{ indentUnit: 4, hangingIndent: 4 },
{ name: "python" }
),
md: CodeMirror.getMode({}, { name: "markdown" }),
css: CodeMirror.getMode({ indentUnit: 2 }, { name: "css" }),
raw: CodeMirror.getMode({}, { name: "text/plain" }),
fetch: CodeMirror.getMode({}, { name: "fetch" })
};
innerModes.raw.startState = () => null;
CodeMirror.defineMode("iomd", () => ({
startState: () => ({
localMode: innerModes.raw,
localState: null
}),
token: (stream, state) => {
CodeMirror.defineMode("jsx", function(config, parserConfig) {
var jsMode = CodeMirror.getMode(config, "javascript");
var xmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true});
function js(stream, state) {
if ((state.jsState.lastType == "operator"
|| state.jsState.lastType == "keyword c"
|| state.jsState.lastType == "=>"
|| /^[\[{}\(,;:]$/.test(state.jsState.lastType))
&& stream.match(/^<[a-zA-Z]+/i, false)) {
state.token = xml;
return xmlMode.token(stream, state.localState);
state.localState = xmlMode.startState(jsMode.indent(state.jsState, ""));
state.localMode = xmlMode;
state.indented = stream.backUp(1);
return xml(stream, state);
}
return jsMode.token(stream, state.jsState);;
CodeMirror.defineMode('htmltwig', function(config, parserConfig) {
return CodeMirror.overlayMode(
CodeMirror.getMode(config, parserConfig.backdrop || 'text/html'),
CodeMirror.getMode(config, 'twig')
)
})
CodeMirror.defineMode("nearley", config =>
CodeMirror.multiplexingMode(
CodeMirror.getMode(config, "ebnf"),
{
open: "{%",
close: "%}",
mode: CodeMirror.getMode(config, "javascript"),
delimStyle: "js-delimit"
},
{
open: /^\s*#/,
close: /.*$/,
mode: CodeMirror.getMode(config, "text/plain"),
delimStyle: "comment-delimit"
}
)
)
stream.next();
return null;
},
blankLine: blankLine
};
var markdownConfig = {
taskLists: true,
strikethrough: true,
emoji: true
};
for (var attr in modeConfig) {
markdownConfig[attr] = modeConfig[attr];
}
markdownConfig.name = "markdown";
return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
}, "markdown");
CodeMirror.defineMode("ql+mustache", function(config) {
return CodeMirror.multiplexingMode(
CodeMirror.multiplexingMode(
CodeMirror.getMode(config, "text/x-overpassQL"),
{open: "{{", close:"}}",
mode:CodeMirror.getMode(config, "text/plain"),
delimStyle: "mustache"}
),
{open: "{{style:", close: "}}",
mode: CodeMirror.getMode(config, "text/css"),
delimStyle: "mustache"}
);
});
CodeMirror.defineMode('nunjucks', (config, parserConfig) => {
const baseMode = CodeMirror.getMode(config, parserConfig.baseMode || 'text/plain');
const nunjucksMode = _nunjucksMode();
return CodeMirror.overlayMode(baseMode, nunjucksMode, false);
});