本文整理汇总了TypeScript中codemirror.defineMIME函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defineMIME函数的具体用法?TypeScript defineMIME怎么用?TypeScript defineMIME使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了defineMIME函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: RegExp
// https://github.com/nteract/nteract/issues/389
import CodeMirror from "codemirror";
import "codemirror/mode/meta";
import "codemirror/mode/python/python";
CodeMirror.defineMode(
"ipython",
(
conf: CodeMirror.EditorConfiguration,
parserConf: any
): CodeMirror.Mode<any> => {
const ipythonConf = Object.assign({}, parserConf, {
name: "python",
singleOperators: new RegExp("^[\\+\\-\\*/%&|@\\^~<>!\\?]"),
identifiers: new RegExp(
"^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*"
) // Technically Python3
});
return CodeMirror.getMode(conf, ipythonConf);
},
"python"
);
CodeMirror.defineMIME("text/x-ipython", "ipython");
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:25,代码来源:ipython.ts
示例2: RegExp
* Define an IPython codemirror mode.
*
* It is a slightly altered Python Mode with a `?` operator.
*/
CodeMirror.defineMode(
'ipython',
(config: CodeMirror.EditorConfiguration, modeOptions?: any) => {
let pythonConf: any = {};
for (let prop in modeOptions) {
if (modeOptions.hasOwnProperty(prop)) {
pythonConf[prop] = modeOptions[prop];
}
}
pythonConf.name = 'python';
pythonConf.singleOperators = new RegExp('^[\\+\\-\\*/%&|@\\^~<>!\\?]');
pythonConf.identifiers = new RegExp(
'^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*'
);
return CodeMirror.getMode(config, pythonConf);
},
'python'
);
CodeMirror.defineMIME('text/x-ipython', 'ipython');
CodeMirror.modeInfo.push({
ext: [],
mime: 'text/x-ipython',
mode: 'ipython',
name: 'ipython'
});
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:30,代码来源:codemirror-ipython.ts
示例3:
import 'codemirror/lib/codemirror';
import 'codemirror/mode/haskell/haskell';
CodeMirror.defineMode("ihaskell", (config) => {
let hmode = CodeMirror.getMode(config, "haskell");
return CodeMirror.multiplexingMode(
hmode,
{
open: /:(?=!)/, // Matches : followed by !, but doesn't consume !
close: /^(?!!)/, // Matches start of line not followed by !, doesn't consume character
mode: CodeMirror.getMode(config, "text/plain"),
delimStyle: "delimit"
},
{
open: /\[r\||\[rprint\||\[rgraph\|/,
close: /\|\]/ ,
mode: CodeMirror.getMode(config, "text/x-rsrc"),
delimStyle: "delimit"}
);
});
CodeMirror.defineMIME("text/x-ihaskell", "ihaskell");
CodeMirror.modeInfo.push({
ext: ['hs'],
mime: "text/x-ihaskell",
mode: 'ihaskell',
name: 'ihaskell'
});
开发者ID:gibiansky,项目名称:IHaskell,代码行数:29,代码来源:codemirror-ihaskell.ts
注:本文中的codemirror.defineMIME函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论