<commit_before>//----------------------------------------------------------------------------
//  Copyright (C) 2012  The IPython Development Team
//
//  Distributed under the terms of the BSD License.  The full license is in
//  the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------

// convert current notebook to html by calling "ipython nbconvert" and open static html file in new tab
"using strict";
   
nbconvertPrintView = function(){
    var kernel = IPython.notebook.kernel;
    var name = IPython.notebook.notebook_name;
    var path = IPython.notebook.notebookPath();
    if (path.length > 0) { path = path.concat('/'); }
    
    var command = 'import os; os.system(\"ipython nbconvert --to html ' + name + '\")';
    function callback(out_type, out_data)
        { 
        console.log('out:', out_data);  
        var url = '/files/' + path + name.split('.ipynb')[0] + '.html';
        var win=window.open(url, '_blank');
        win.focus();
        }
    kernel.execute(command, { shell: { reply : callback } });
};

IPython.toolbar.add_buttons_group([
    {
        id : 'doPrintView',
        label : 'Create static print view',
        icon : 'icon-print',
        callback : nbconvertPrintView
    }
]);

<commit_msg>Add version check for notebook path<commit_after>//----------------------------------------------------------------------------
//  Copyright (C) 2012  The IPython Development Team
//
//  Distributed under the terms of the BSD License.  The full license is in
//  the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------

// convert current notebook to html by calling "ipython nbconvert" and open static html file in new tab
"using strict";
   
nbconvertPrintView = function(){
    var kernel = IPython.notebook.kernel;
    var name = IPython.notebook.notebook_name;
    
    if (IPython.version[0] == "2") {
        var path = IPython.notebook.notebookPath();
        if (path.length > 0) { path = path.concat('/'); }
    } else {
        var path = "";
    }
    
    var command = 'import os; os.system(\"ipython nbconvert --to html ' + name + '\")';
    function callback(out_type, out_data)
        { 
        var url = '/files/' + path + name.split('.ipynb')[0] + '.html';
        var win=window.open(url, '_blank');
        win.focus();
        }
    kernel.execute(command, { shell: { reply : callback } });
};

IPython.toolbar.add_buttons_group([
    {
        id : 'doPrintView',
        label : 'Create static print view',
        icon : 'icon-print',
        callback : nbconvertPrintView
    }
]);


{'fraction_non_alphanumeric': 0.2321889996308601, 'fraction_numerical': 0.00516795865633075, 'mean_word_length': 1.7484787018255579, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4415725', 'n_tokens_mistral': 761, 'n_tokens_neox': 747, 'n_words': 219}