fixing code mirror mode to ignore :! things

This commit is contained in:
Andrew Gibiansky 2014-01-06 13:26:32 -05:00
parent 7f23e743b7
commit 92361c93c2
2 changed files with 20 additions and 5 deletions

View File

@ -4,6 +4,10 @@ rm -f profile.tar
tar -cvf profile.tar *
cd ..
cabal install --force-reinstalls || exit 1
# Remove my profile
rm -rf ~/.ipython/profile_haskell
cd ihaskell-display
for dir in `ls`
do
@ -11,6 +15,3 @@ do
cabal install || exit 1
cd ..
done
# Remove my profile
rm -rf ~/.ipython/profile_haskell

View File

@ -17,6 +17,20 @@ $([IPython.events]).on('app_initialized.NotebookApp', function(){
// of codecell highlight.
CodeMirror.requireMode('haskell', function(){
// Create a multiplexing mode that uses Haskell highlighting by default but
// doesn't highlight command-line directives.
CodeMirror.defineMode("ihaskell", function(config) {
return CodeMirror.multiplexingMode(
CodeMirror.getMode(config, "haskell"),
{
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"
}
);
});
cells = IPython.notebook.get_cells();
for(var i in cells){
c = cells[i];
@ -24,7 +38,7 @@ $([IPython.events]).on('app_initialized.NotebookApp', function(){
// Force the mode to be Haskell
// This is necessary, otherwise sometimes highlighting just doesn't happen.
// This may be an IPython bug.
c.code_mirror.setOption('mode', 'haskell');
c.code_mirror.setOption('mode', 'ihaskell');
c.auto_highlight()
}