答案 0 :(得分:1)
以下代码在笔记本5.x中放置在〜/ .jupyter / custom / custom.js中时可用于SQL:
require(['notebook/js/codecell'], function(codecell) {
codecell.CodeCell.options_default.highlight_modes['magic_text/x-mssql'] = {'reg':[/^%%sql/]} ;
Jupyter.notebook.events.one('kernel_ready.Kernel', function(){
Jupyter.notebook.get_cells().map(function(cell){
if (cell.cell_type == 'code'){ cell.auto_highlight(); } }) ;
});
});
答案 1 :(得分:0)
JavaScript版本:
%%js
require(['notebook/js/codecell'], (codecell) => {
codecell.CodeCell.options_default.highlight_modes.magic_javascript =
{reg: [/^%%(?:js|javascript|script node)/]}
Jupyter.notebook.events.one('kernel_ready.Kernel', () => {
Jupyter.notebook.get_cells().map((cell) => {
if (cell.cell_type == 'code'){
cell.auto_highlight()
}})
})
})