<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { NotebookSerializer } from './notebookSerializer';

export function activate(context: vscode.ExtensionContext) {
	context.subscriptions.push(vscode.workspace.registerNotebookSerializer('jupyter-notebook', new NotebookSerializer(context), {
		transientOutputs: false,
		transientCellMetadata: {
			breakpointMargin: true,
			inputCollapsed: true,
			outputCollapsed: true,
			custom: false
		}
	}));<commit_msg>Add ipynb extension API to invoke the serializer. So the jupyter extension can implement custom Export functionality, and can dump an unsaved notebook #128495<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { NotebookSerializer } from './notebookSerializer';

export function activate(context: vscode.ExtensionContext) {
	const serializer = new NotebookSerializer(context);
	context.subscriptions.push(vscode.workspace.registerNotebookSerializer('jupyter-notebook', serializer, {
		transientOutputs: false,
		transientCellMetadata: {
			breakpointMargin: true,
			inputCollapsed: true,
			outputCollapsed: true,
			custom: false
		}
	}));

	return {
		exportNotebook: (notebook: vscode.NotebookData): Uint8Array => {
			return exportNotebook(notebook, serializer);
		}
	};
}

function exportNotebook(notebook: vscode.NotebookData, serializer: NotebookSerializer): Uint8Array {
	return serializer.serializeNotebook(notebook, new vscode.CancellationTokenSource().token);
{'fraction_non_alphanumeric': 0.2496506753609688, 'fraction_numerical': 0.0037261294829995344, 'mean_word_length': 2.3354037267080745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5980838', 'n_tokens_mistral': 543, 'n_tokens_neox': 517, 'n_words': 142}